<?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>nRF52 bug</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76933/nrf52-bug</link><description>Hello! 
 Apologies in advance for my english. 
 I already asked a similar question, here is the link to it 
 When trying to connect a PWM driver PCA9685, I ran into problems that are software 
 Here are my user files that I used 
 I also use the development</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Jul 2021 11:36:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76933/nrf52-bug" /><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318617?ContentTypeID=1</link><pubDate>Mon, 05 Jul 2021 11:36:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:626ed6dc-ba97-4ecf-9a87-753a8476b84d</guid><dc:creator>Nur2705</dc:creator><description>&lt;p&gt;thank you very much for answering in detail&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318568?ContentTypeID=1</link><pubDate>Mon, 05 Jul 2021 08:22:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3357fb83-054b-4434-8dc8-d88723e33c2c</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;When you&amp;#39;re using an event handler in nrf_drv_twi_init(), TWI driver works in async mode -&amp;nbsp;nrf_drv_twi_tx() returns immediately, transaction continues at background. There are two consequences to make your code stable:&lt;/p&gt;
&lt;p&gt;1) you should wait for transaction to finish before sending a next one. If you&amp;#39;re using a flag that is set in event handler by&amp;nbsp;&lt;em&gt;NRF_DRV_TWI_EVT_DONE&lt;/em&gt;&lt;span&gt;&amp;nbsp;event, don&amp;#39;t forget to define that flag with&amp;nbsp;&lt;em&gt;volatile&lt;/em&gt; keyword.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;2) automatic variable should not be used for tx buffer, because its content will likely be destroyed before transaction is finished. Define your buffer as&amp;nbsp;&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;static uint8_t buff[2].&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318554?ContentTypeID=1</link><pubDate>Mon, 05 Jul 2021 07:31:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23a3b4c4-b817-4166-89b5-89da6091a019</guid><dc:creator>Nur2705</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&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:
            m_xfer_done = true;
            break;
        default:
            break;
    }
}
/**
 * @brief TWI initialization.
 */
void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_lm75b_config = {
       .scl                = 27,
       .sda                = 26,
       .frequency          = NRF_DRV_TWI_FREQ_400K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_lm75b_config, twi_handler, NULL);
            NRF_LOG_INFO(&amp;quot;\r\n nrf_drv_init = %d&amp;quot;,err_code);
    NRF_LOG_FLUSH();
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
} &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318392?ContentTypeID=1</link><pubDate>Fri, 02 Jul 2021 09:58:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6294a798-182d-4b49-b57d-c67a585fe7c1</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Nursultan, could you show your TWI initialization code (&lt;span&gt;nrf_drv_twi_init&lt;/span&gt;)? Are you using any&amp;nbsp;&lt;em&gt;event_handler&lt;/em&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318354?ContentTypeID=1</link><pubDate>Fri, 02 Jul 2021 08:03:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a23d4b0-71e1-470f-ac78-33149505f302</guid><dc:creator>Nur2705</dc:creator><description>&lt;p&gt;Hello&lt;br /&gt;I rebuilt the &lt;a href="https://github.com/Nursultan-Salikhov/PCA9685-with-NRF52-DK"&gt;whole project&lt;/a&gt; and now it works&lt;br /&gt;What was the reason, I never figured out&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 bug</title><link>https://devzone.nordicsemi.com/thread/318230?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 12:54:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:949d1c26-800d-494e-8414-c6125248ff84</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Could you please include the file (main.c maybe?) where these functions are being called as well? I would like to see your TWI initialization.&lt;/p&gt;
&lt;p&gt;Also, please add error checking like Jared suggested your other ticket. This makes it much easier to catch errors.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;strong&gt;err_code&lt;/strong&gt; = nrf_drv_twi_tx(&amp;amp;m_twi, slave_addr, reg, 1, false);&lt;br /&gt;&lt;strong&gt;APP_ERROR_CHECK&lt;/strong&gt;(&lt;strong&gt;err_code&lt;/strong&gt;); // Check if error_code == NRF_SUCCESS before continuing &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>