<?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>Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85779/linker-error-when-merging-twi-examples-into-ble_app_uart</link><description>Hello, 
 as I see , many in DevZone have had a problem like this: we tried to merge twi-functionality into the basic ble_app_uart example. We set proper defines in sdk_config .h, we add missing .c files, and we add include paths, but the linker just complains</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Mar 2022 10:23:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85779/linker-error-when-merging-twi-examples-into-ble_app_uart" /><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/358369?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2022 10:23:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae172d92-fb82-41e9-b2a9-51b28f8953ba</guid><dc:creator>Pero Krivic</dc:creator><description>&lt;p&gt;Awesome, thanks for the explanation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/358363?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2022 10:01:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55a1d289-ae33-44ac-b173-2b868294c276</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The TWI scanner example in the SDK is built to be run in blocking mode. The function will return a&amp;nbsp;NRF_SUCCESS only if it finds a slave on the bus and the transfer is successful.&lt;/p&gt;
&lt;p&gt;However, if the driver is used in non blocking mode, then the function will return immediately, before the transfer has finished with a&amp;nbsp;&lt;span&gt;NRF_SUCCESS. It will then eventually generate a&amp;nbsp;&lt;/span&gt;nrf_drv_twi_evt_type_t event that indicates if the transfer was successful or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Because the function returns immediately with&amp;nbsp;&lt;span&gt;NRF_SUCCESS in non-blocking mode, the example code will interpret&amp;nbsp;this as a device has been found on the address.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jared&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/358297?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2022 19:29:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c46828a-fbdd-40e5-8fd3-35de8aef8581</guid><dc:creator>Pero Krivic</dc:creator><description>&lt;p&gt;Hi, I have added a dummy handler function like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief TWI events handler.
 */
void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
    switch (p_event-&amp;gt;type)
    {
        case NRF_DRV_TWI_EVT_DONE:
            if (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_RX)
            {
               NRF_LOG_INFO(&amp;quot;\n\rTWI Data handler&amp;quot;);
               NRF_LOG_FLUSH();
            }
            //m_xfer_done = true;
            break;
        default:
            break;
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then if I make my init function like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, &amp;amp;twi_handler, NULL);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;the twi_scanner example finds a device at every address.But if I exlude the handler pointer, like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;it works fine again.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why is that so?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/358129?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2022 08:38:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:203c4412-ffb4-4ece-804a-7047e46b6a2c</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hmm, I can&amp;#39;t see how that would make any difference. Not providing a handler to the initialize function means the driver will be configured in &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_twi.html?cp=8_1_2_0_17_1#hardware_driver_twi_basic"&gt;blocking mode&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/357956?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 13:08:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3669975b-ac83-4d66-9e31-38b3061fa8c6</guid><dc:creator>Pero Krivic</dc:creator><description>&lt;p&gt;Hi Jared, thanks for the reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am using nRF52-DK, unmodified, so everything shoud be as shipped.&lt;/p&gt;
[quote userid="73165" url="~/f/nordic-q-a/85779/linker-error-when-merging-twi-examples-into-ble_app_uart/357941#357941"]Is your code based on twi_sensor or tw_scanner?&amp;nbsp;[/quote]
&lt;p&gt;I have tried both. For the clarity,&amp;nbsp;the last time I was testing the setup, i used twi_scanner (which retourned positive for every address it has scanned).&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;P&lt;/p&gt;
&lt;p&gt;EDIT: hello, the issue seems to have been solved when the handler is excluded from the twi_init function, that is if the init is called like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_lm75b_config, NULL, NULL);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;now the scanner works and no twi device is detected, as it should be. Originally, I had the handler address sent to init function (leftover from twi_sensor example).&lt;/p&gt;
&lt;p&gt;Why is that so? Why the scanner example makes trouble if the handler address is passed through?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Linker error when merging twi-examples into ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/357941?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 12:40:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87e01023-1f3b-43ff-96d9-cccec76a6b54</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If it builds fine without any errors, then I think we can assume that everything is included for it to work. The culprit might be related to something else.&lt;/p&gt;
[quote user=""] the scanner application returned true for every address probed (but obviously there should be no devices present).[/quote][quote user=""]copied the main.c code from twi_sensor into my main.c[/quote]
&lt;p&gt;Is your code based on twi_sensor or tw_scanner?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What pin are you using for the SDA line and is it connected to something externally? Do you get the same result if you connect the pin to VDD?&lt;/p&gt;
&lt;p&gt;regards&lt;br /&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>