<?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>How do I recover from a failed I2C write?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13852/how-do-i-recover-from-a-failed-i2c-write</link><description>By design, the TI LP55231 LED driver IC will fail the TWI write of the reset register (0x3D). It&amp;#39;s necessary to reset the IC in an edge use case. I&amp;#39;m using the nRF51822 HW TWI driver and cannot recover from this. The first write returns without error</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 May 2016 14:14:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13852/how-do-i-recover-from-a-failed-i2c-write" /><item><title>RE: How do I recover from a failed I2C write?</title><link>https://devzone.nordicsemi.com/thread/52931?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 14:14:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3fe33e2-71ee-43d6-9947-151d889b07bd</guid><dc:creator>zhwzh308</dc:creator><description>&lt;p&gt;Then you will have to uninit nrf_drv_twi, and init again. Do this in the error handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I recover from a failed I2C write?</title><link>https://devzone.nordicsemi.com/thread/52932?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 02:14:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc54547d-aad1-4784-b6b0-ba612bc7af64</guid><dc:creator>olduvai</dc:creator><description>&lt;p&gt;Thanks but that doesn&amp;#39;t help. ALL successive writes fail with NRF_ERROR_INTERNAL after the initial problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I recover from a failed I2C write?</title><link>https://devzone.nordicsemi.com/thread/52930?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 00:27:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:990c4bb4-0c78-499c-b370-b0bfc5448ddb</guid><dc:creator>zhwzh308</dc:creator><description>&lt;p&gt;Just skip APP_ERROR_CHECK and replace it with if statement, or if you really want to do this properly, define your own fault handler in this form: &lt;code&gt;void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)&lt;/code&gt;. This essentially overrides the weakly defined &lt;code&gt;app_error_fault_handler&lt;/code&gt; so you can define routine to handle specific error from your code.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**
 * Function is implemented as weak so that it can be overwritten by custom application error handler
 * when needed.
 */
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
{
    // On assert, the system can only recover with a reset.
#ifndef DEBUG
    NVIC_SystemReset(); // Override this if you like, so it does not reboot
#else

#ifdef BSP_DEFINES_ONLY
    LEDS_ON(LEDS_MASK); // Only runs if you have Board Support Package with LEDs configured
#else
    UNUSED_VARIABLE(bsp_indication_set(BSP_INDICATE_FATAL_ERROR));
    // This call can be used for debug purposes during application development.
    // @note CAUTION: Activating this code will write the stack to flash on an error.
    //                This function should NOT be used in a final product.
    //                It is intended STRICTLY for development/debugging purposes.
    //                The flash write will happen EVEN if the radio is active, thus interrupting
    //                any communication.
    //                Use with care. Uncomment the line below to use.
    //ble_debug_assert_handler(error_code, line_num, p_file_name);
#endif // BSP_DEFINES_ONLY

    app_error_log(id, pc, info);
//    app_error_save_and_stop(id, pc, info); // You may want to continue your code execution.

#endif // DEBUG
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>