<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Can&amp;#39;t instantiate uart driver</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18616/can-t-instantiate-uart-driver</link><description>Hello all, 
 I try to instantiate an uart driver using NRF_DRV_UART_INSTANCE macro, but I got the following error : 
 sdk/components/drivers_nrf/uart/nrf_drv_uart.h:97:1: error: invalid conversion from &amp;#39;void*&amp;#39; to &amp;#39;NRF_UARTE_Type*&amp;#39; [-fpermissive]
 </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Dec 2016 14:29:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18616/can-t-instantiate-uart-driver" /><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71890?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 14:29:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95389763-0fc0-44df-a2fa-f3efb31debd3</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;hello,
that&amp;#39;s compile, I also modify this code part :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;typedef struct
{
    union
    {
#if (defined(UART_IN_USE) || (UART_ENABLED == 0))
    NRF_UART_Type * p_uart;   ///&amp;lt; Pointer to a structure with UART registers.
#endif
#if (defined(UARTE_IN_USE))
    NRF_UARTE_Type * p_uarte; ///&amp;lt; Pointer to a structure with UARTE registers.
#endif

    } reg;
    uint8_t drv_inst_idx;     ///&amp;lt; Driver instance index.
} nrf_drv_uart_t;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and I suppress the p_uart = in the NRF_DRV_UART_INSTANCE macro.
As I said, the program compile, but it didn&amp;#39;t work, this is my main function :&lt;/p&gt;
&lt;p&gt;#define BSP_UART_SUPPORT
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;sdk_config.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;&lt;/p&gt;
&lt;p&gt;#include &amp;quot;nrf_drv_uart.h&amp;quot;&lt;/p&gt;
&lt;p&gt;const nrf_drv_uart_t uart_test = NRF_DRV_UART_INSTANCE(0);&lt;/p&gt;
&lt;p&gt;void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context)
{
//static uint8_t rec_byte=0;
switch(p_event-&amp;gt;type)
{
case NRF_DRV_UART_EVT_RX_DONE:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    break;

    case NRF_DRV_UART_EVT_ERROR:

    default:
    break;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;int main(void)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/*Parameters for uart driver*/
uint32_t err_code;
nrf_drv_uart_config_t uart_cfg;

uart_cfg.pseltxd        = RX_PIN_NUMBER;
uart_cfg.pselrxd        = TX_PIN_NUMBER;
uart_cfg.pselcts        = RTS_PIN_NUMBER;
uart_cfg.pselrts        = CTS_PIN_NUMBER;
uart_cfg.hwfc           = NRF_UART_HWFC_DISABLED;
uart_cfg.parity         = NRF_UART_PARITY_EXCLUDED;
uart_cfg.baudrate       = NRF_UART_BAUDRATE_115200;
uart_cfg.use_easy_dma   = true;

err_code = nrf_drv_uart_init(&amp;amp;uart_test,&amp;amp;uart_cfg,uart_event_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_uart_rx_enable(&amp;amp;uart_test);
uint8_t test[4]={0,255,0,255};
static uint8_t i=0;

while( true )
{
  while(i&amp;lt;4)
  {
      err_code = nrf_drv_uart_tx(&amp;amp;uart_test, &amp;amp;test[i], 1);
      if(err_code ==NRF_SUCCESS )
      {
      }
      nrf_delay_ms(1000);
      i++;
  }
  i=0;
};
return 0;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;in the oscilloscope, I don&amp;#39;t have any signal in Tx output pin :/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71889?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 13:37:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a17fdb59-2e1f-4fd0-8ffc-3b6910e6ee1a</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What if you do:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define NRF_DRV_UART_INSTANCE(id)                            \
{                                                            \
    .reg          = {p_uart = NRF_DRV_UART_PERIPHERAL(id)},           \
    .drv_inst_idx = CONCAT_3(UART, id, _INSTANCE_INDEX),\
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define NRF_DRV_UART_INSTANCE(id)                            \
{                                                            \
    .reg          = {p_uart = (NRF_UART_Type*)NRF_DRV_UART_PERIPHERAL(id)},           \
    .drv_inst_idx = CONCAT_3(UART, id, _INSTANCE_INDEX),\
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;instead of&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define NRF_DRV_UART_INSTANCE(id)                            \
{                                                            \
    .reg          = {NRF_DRV_UART_PERIPHERAL(id)},           \
    .drv_inst_idx = CONCAT_3(UART, id, _INSTANCE_INDEX),\
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71882?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 13:22:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db649202-8356-4e1c-a520-a3206c38e6ed</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;because I instatiate differently my UART : uart_inst.drv_inst_idx = CONCAT_3(UART, 0, _INSTANCE_INDEX);
but I am not sur that&amp;#39;s the right way to instatiate the program!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71881?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 13:17:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfb2c333-af5c-402d-9ac4-1123156cfc02</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You said &amp;quot;That&amp;#39;s compile&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71880?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 13:16:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f28f8c7c-e26f-4cc4-b55d-522e356e90f3</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;No! because, the program didn&amp;#39;t compile :/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71879?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 13:15:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f5c7bac-6dcf-4cec-932c-f7986d0ed426</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;And the UART works? It looks similar to what is suggested &lt;a href="https://devzone.nordicsemi.com/question/83125/error-when-using-c-with-twi/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71888?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 12:45:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:231eb653-a2df-4c0e-a758-860adcab6f19</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;I use g++ in my code!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71887?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 11:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c09fcf75-ec9a-4964-989c-abd3bef05415</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You are using C++? Should you then use g++ not gcc? I just tried to compile with gcc and I don&amp;#39;t get any errors with the code in my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71877?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 10:25:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:954ab2a0-cbbb-4537-85f5-f1a29d367702</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;I did! it was an error of compressing file, I juste add sdk_config file, and the compiler name, all the project is heavy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71886?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 10:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ecd3872-d601-4388-b003-7d3ec1fc4953</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;I did! it was an error of compressing file, I juste add sdk_config file, and the compiler name, all the project is heavy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71876?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 10:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37af6c80-9413-4b9d-9200-f89c4ab26b5d</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;The zip you uploaded only contains one empty folder. What toolchain are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71885?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 09:35:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e3e0698-b2c4-4220-99cc-4d53e850d460</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. What toolchain are you using? Could you share your complete project so I can test it here? You can edit your original question and upload it there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71884?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 09:26:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9e2028c-2889-4a0e-aa80-8a3d2da04e8b</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;I tried this solution, but the error persist, I still have this error message :&lt;/p&gt;
&lt;p&gt;sdk/components/drivers_nrf/uart/nrf_drv_uart.h:97:1: error: invalid conversion from &amp;#39;void*&amp;#39; to &amp;#39;NRF_UARTE_Type*&amp;#39; [-fpermissive]
}
^
drivers/uart.hpp:20:29: note: in expansion of macro &amp;#39;NRF_DRV_UART_INSTANCE&amp;#39;
const nrf_drv_uart_t uart = NRF_DRV_UART_INSTANCE(0);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71883?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 09:20:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7fc2077-69a7-4ce9-b262-b27dc23d4a3b</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You should do something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf_drv_uart.h&amp;quot;

const nrf_drv_uart_t uart = NRF_DRV_UART_INSTANCE(0);

void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context)
{
}

void initUART()
{
    uint32_t err_code;
    nrf_drv_uart_config_t uart_cfg;

    uart_cfg.pseltxd        = RX_PIN_NUMBER;
    uart_cfg.pselrxd        = TX_PIN_NUMBER;
    uart_cfg.pselcts        = RTS_PIN_NUMBER;
    uart_cfg.pselrts        = CTS_PIN_NUMBER;
    uart_cfg.hwfc           = NRF_UART_HWFC_DISABLED;
    uart_cfg.parity         = NRF_UART_PARITY_EXCLUDED;
    uart_cfg.baudrate       = NRF_UART_BAUDRATE_115200;
    uart_cfg.use_easy_dma   = true;

    err_code = nrf_drv_uart_init(&amp;amp;uart, &amp;amp;uart_cfg, uart_event_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_uart_rx_enable(&amp;amp;uart);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71875?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2016 15:58:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:097da5ff-3fac-4f13-ae15-2597eb7ad01c</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;12.1.0 version&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71874?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2016 15:27:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba2428f8-30cb-46fd-a898-ec33abdbbc8f</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;What SDK are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't instantiate uart driver</title><link>https://devzone.nordicsemi.com/thread/71878?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2016 13:58:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61008941-392b-4ccb-a5ab-5e57fdcabc8d</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;hello again; I made a modification, I instantiate separatly the uart declaration and the instance index, as bellow :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void initUART()
{
    nrf_drv_uart_t uart_inst;
    uart_inst.drv_inst_idx = CONCAT_3(UART, 0, _INSTANCE_INDEX);

    uint32_t err_code;
    nrf_drv_uart_config_t uart_cfg=NRF_DRV_UART_DEFAULT_CONFIG;

    uart_cfg.pseltxd=RX_PIN_NUMBER;
    uart_cfg.pselrxd=TX_PIN_NUMBER;
    uart_cfg.pselcts=RTS_PIN_NUMBER;
    uart_cfg.pselrts=CTS_PIN_NUMBER;
    uart_cfg.hwfc=(nrf_uart_hwfc_t)UART_CONFIG_HWFC_Disabled;
    uart_cfg.parity=(nrf_uart_parity_t)false;
    uart_cfg.baudrate=(nrf_uart_baudrate_t)UART_BAUDRATE_BAUDRATE_Baud115200;

    err_code = nrf_drv_uart_init(&amp;amp;uart_inst, &amp;amp;uart_cfg, uartEventHandler);
    nrf_drv_uart_rx_enable(&amp;amp;uart_inst);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&amp;#39;s compile, but i don&amp;#39;t know that i made the right instantiation? o_O&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>