<?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>twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62583/twi-fail-in-second-msg-attempt</link><description>hello 
 
 i am using nrf52832, with ble (s132 softdevice), pwm drv, saadc drcm uart, and using app_timers 
 i have added the twi drv to work with an expander for start. 
 this is how my function looks like 
 
 this is where i call the function: 
 
 first</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 15 Jun 2020 13:34:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62583/twi-fail-in-second-msg-attempt" /><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255046?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 13:34:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f04d0389-34bb-42d8-809c-3ff75d151121</guid><dc:creator>ziv123</dc:creator><description>[quote userid="2111" url="~/f/nordic-q-a/62583/twi-fail-in-second-msg-attempt/255040"]all together in main(). Having the soc hardware handle this all by itself isn&amp;#39;t really possible[/quote]
&lt;p dir="LTR"&gt;&lt;span style="background:white;color:black;font-family:&amp;#39;Arial&amp;#39;,sans-serif;font-size:9.0pt;"&gt;i do not expect the hardware to deal with a malfunction if it accurse but to alert and maybe abort pervious operation, but like the saadc driver knows to read one pin (channel) and after finishing its readings move to the next defined pin and so on and can even trigger a high or low limit compar.. then i do belive some things can be done without CPU intervention on the driver side.. i understand that the current twi driver can not do that ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255040?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 13:19:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae59a375-491a-4f04-a604-e69b26378200</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Feel free to modify this the best to your needs and requirement. It may be twi sensors that based on your experience malfunction, and you want to handle this gracefully in your application. You may for instance add a down counter in your while() loop, and that way get out of a stuck situation or your twi callback handler can handle a twi que, and thereby you may avoid having a while() all together in main(). Having the soc hardware handle this all by itself isn&amp;#39;t really possible if you assume that a malfunction can occur, since the hardware will not be able to identify such an occurrence either. So you will need (at least the way I see it) add additional handling of errors and timeouts for transfer in your application, if&amp;nbsp; based on your experience see that this occurs from time to time. My impression is that these kind of error occurs frequently during development due to timing constrains not followed, pull-ups not mounted, register access is not allowed or errors in twi transfers break for instance the usage of twi either on the master or slave, however once these have been identified during development, then simple while() loops do work.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255029?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 13:01:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9f70f91-a299-456c-94e9-ba63df062742</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;I am sorry if my replay maybe a bit rude but I wonder if you think I am stupid :/&lt;/p&gt;
&lt;p&gt;i am sorry to say but the use of a bool flag in a while loop is not the most clever solution one can think of..&lt;/p&gt;
&lt;p&gt;let&amp;#39;s say that for some reason there is a malfunction in the twi tx and i never get the event of type &amp;#39; NRF_DRV_TWI_EVT_DONE &amp;#39;,&amp;nbsp; the way it is implemented in the example i get stuck in the while loop forever and i am sure my employer will not like that so much, also there is no functional difference if i wait in delay or wait in a loop, still my program is missing a whole many things that maybe happening now&lt;/p&gt;
&lt;p&gt;this is why I asked if there is a way to let the &amp;quot;hardware&amp;quot; do that work ,of waiting and managing the send of the buffered msg, which is always a good practice in embedded&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255018?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 12:39:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3ad96d0-04f2-46a8-ac94-9a6cf37d936c</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;If you look at&amp;nbsp;\examples\peripheral\twi_sensor you can for instance find how to use a &amp;#39;m_xfer_done&amp;#39; flag to notify when the previous transaction is finished.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255014?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 12:32:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:220b2a72-8b50-46c6-8193-6810d3b93999</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;hi Kenneth&lt;/p&gt;
&lt;p&gt;i added 10 ms delay between one call to the next and i so everything passing good on the ociloscop&lt;/p&gt;
&lt;p&gt;still, it is not something i want to do in my program to creat a delay or configure another timer just for the second twi tx, is there anyway to avoide that or any mechanism, like using the DMA as buffer for the next message and the driver will collect and transmit the msg from there once the first message receivs the desirable Ack ??&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Ziv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/255004?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 12:17:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdb1b71f-8d0b-4a2b-a41c-a14b181c1e9b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;The first I would recommend it simply drag in the example code as-is from the nRF5 SDK twi example to check that it works as intended. For instance a logic analyzer is very valuable to check if data is sent and acked as intended. In your case you have&amp;nbsp;set &amp;#39;twi_handler&amp;#39; in&amp;nbsp;nrf_drv_twi_init() so this means that the &amp;#39;twi_handler()&amp;#39; should execute after transfer to indicate if data was sent successfully or not. The error code&amp;nbsp;&lt;span&gt;17 from&amp;nbsp;nrf_drv_twi_tx() I can see from nrf_drv_twi.h is&amp;nbsp;NRF_ERROR_BUSY, which make sense since the previous call is not yet finished here. Make sure you have included all &amp;#39;TWI&amp;#39; defines from the nRF5 SDK twi example sdk_config.h to your sdk_config.h. Make sure that the TWI pins have pull-up resistors.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: twi fail in second msg attempt</title><link>https://devzone.nordicsemi.com/thread/254919?ContentTypeID=1</link><pubDate>Mon, 15 Jun 2020 08:50:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45b94d22-1f4b-46e6-a6ec-a46aee46130a</guid><dc:creator>ziv123</dc:creator><description>&lt;p&gt;one more this .. when i run in debug mode i see that i am not entering the event handler at all so it is not so clear to me what i am doing wrong ???&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>