<?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>Handling ret_code_t errors (SDK14.2)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30701/handling-ret_code_t-errors-sdk14-2</link><description>I&amp;#39;m trying to understand how to handle error codes from the twi driver at the moment. When I hold my I2C slave in reset and try to configure it nrf_drv_twi_tx() returns 0x8201 which I was able to figure out how to decode by looking through the sdk_errors</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Feb 2018 11:15:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30701/handling-ret_code_t-errors-sdk14-2" /><item><title>RE: Handling ret_code_t errors (SDK14.2)</title><link>https://devzone.nordicsemi.com/thread/121502?ContentTypeID=1</link><pubDate>Wed, 21 Feb 2018 11:15:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a54d2e67-fb84-4967-bcb6-e0a9ea473982</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Error code 0x8201 means &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Fgroup__drv__specific__errors.html"&gt;NRF_ERROR_DRV_TWI_ERR_ANACK&lt;/a&gt;, and the possible return codes from the function call is given in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__drv__twi.html#ga2c5ea8408254dfa9cbff55dbee171a95"&gt;function API docuementation&lt;/a&gt;.&amp;nbsp;I&amp;#39;m not sure what you mean by &amp;quot;&lt;span&gt;Should I mask the return code and check the LSB only?&amp;quot;. Why would you mask out part of the error code?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Not all error codes are non-recoverable. You need to decide this when you write your application. If it is acceptable in your application to for instance get an address NACK, you can mask out these errors while passing the rest of the error codes to&amp;nbsp;APP_ERROR_CHECK(), using a if-check:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t err_code = nrf_drv_twi_tx(....);
if(err_code != NRF_ERROR_DRV_TWI_ERR_ANACK)
{
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is no need to reset the device, This is just the default recovery method used in the SDK. You can write your own &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.1.0/group__app__error.html#ga99cd7671f5eca2fdd40980d3ebe5b84a"&gt;app_error_fault_handler&lt;/a&gt;&amp;nbsp;function, that will handle all general error codes based on your opinion of the seriousness/recoverability.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>