<?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>Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44420/correct-order-of-nrf_drv_twi-commands</link><description>Hi, I try to read data from the ICM20948 IMU with I2C from my nRF 52840 DK. 
 Initialization of the device is correct, the IMU ID is sent to nRF correctly which means that the TWI protocol works fine but when I initiate the process to read the accelerometer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 24 Apr 2019 12:20:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44420/correct-order-of-nrf_drv_twi-commands" /><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/183443?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 12:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b68ce7-b580-4a6f-b90f-ea0fe194c6c4</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Use nrf_drv_twi.h . Basicaly what you need to do as a first step would be to read the device ID of ICM20948. The code for the ID is given in the sensor&amp;#39;s datasheet.&lt;/p&gt;
&lt;p&gt;If you receive the same ID with the datasheet then your TWI&amp;nbsp; communication is working. If you receive garbage data, check the TWI handler function and the places you assign your twi_xfer_done flag to false. Also you should note that it is a good practice to reset the ICM20948 before performing anything else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/183367?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 09:04:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79085177-d361-4141-8f3d-91b498d2ca91</guid><dc:creator>nikhilesh</dc:creator><description>&lt;p&gt;Hello masterLee,&lt;/p&gt;
&lt;p&gt;I am using nrf52840 with SDK 15.3. I see a lot of twi drivers and its confusing which one to use. I want to read the ICM 20948 sensor data in burst mode for my application. In the second step I want to use the tap detection in DMP, so i have to write the DMP firmware into the ICM. But my twi drivers seem to constantly return with err_code 0x11 or 0x03 errors. Please let me know which is the best twi drivers for ICM. Your help would be much appreciated. Thanks and regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/178430?ContentTypeID=1</link><pubDate>Tue, 26 Mar 2019 14:39:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58049a2b-b420-494a-b42e-0badf1a7d0b9</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi Kenneth, sorry for the delayed answer. I modified the ICM20948 example and transferred it to the Dongle. The example now functions with 400k speed. This leads me to assume that the pull-up resistors of the I2C on the DK are different from those on my ICM module.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/175417?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 15:00:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a9c8f2f-1d02-434e-8346-099f1290375d</guid><dc:creator>Kenneth</dc:creator><description>[quote user="masterLee"]Is there any way that I can configure the MCU clock source since&amp;nbsp; TWI depends on HFCLK source?[/quote]
&lt;p&gt;Sorry no.&lt;/p&gt;
&lt;p&gt;I have ordered an&amp;nbsp;&lt;span&gt;ICM20948&amp;nbsp;from ebay, and if you can provide a project I may run on a nRF52-DK then I can try to recreate it as soon as I received it.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174844?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 15:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb3cb6e-ac45-422e-b9f7-68406f4b9701</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp; The best thing would be if you could test it with an ICM20948 ic.... but since this might not be feasible maybe&amp;nbsp;you could test the protocol in different SCL fequencies with an other I2C sensor .&lt;/p&gt;
&lt;p&gt;I tested it at 100,250,400 and 416kHz. The first two simply do not return nothing. They produce DNACK error . The 400kHz works sometimes and 416kHz all the time.&lt;/p&gt;
&lt;p&gt;Is there any way that I can configure the MCU clock source since&amp;nbsp; TWI depends on HFCLK source?&amp;nbsp;&amp;nbsp; &amp;nbsp; Apart from that&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174834?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 14:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aab3f58b-1b7a-43b1-983f-78d2d88deac0</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I don&amp;#39;t know what might be the problem here, can you think of any way I may be able to recreate it here using an nRF52840-DK?&lt;/p&gt;
&lt;p&gt;I have searched a bit on the forum, I could find this case, but that one seems to be working:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/42254/twi-inconsistent-read-of-slave-device-address-location-in-nrf5-sdk-15-2"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/42254/twi-inconsistent-read-of-slave-device-address-location-in-nrf5-sdk-15-2&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174719?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 07:44:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfb7c356-6fc5-4e27-b04c-90f12f986438</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Good Morning.&lt;/p&gt;
&lt;p&gt;Yes the same thing happens when I set the&amp;nbsp;#define TWI0_USE_EASY_DMA 0&amp;nbsp;&amp;nbsp;&amp;nbsp; or &amp;nbsp; when I try TWI it in blocking mode.&lt;/p&gt;
&lt;p&gt;Sometimes ERROR 33282 [NRF_ERROR_DRV_TWI_ERR_DNACK] is produced and other times the program just stalls. If I apply both options then this error is produced all the time.&lt;/p&gt;
&lt;p&gt;Is there any chance that the NRF_LOG_INFO () that I use to print messages, produce some problem ? I have set deferred mode to unchecked.&lt;/p&gt;
&lt;p&gt;Last minute progress: I increased the TWI clock from 400kHz to&amp;nbsp; 416kHz by adding a new definition in the nrf52840_bitfields.h (&amp;nbsp;#define TWI_FREQUENCY_FREQUENCY_K&amp;nbsp; (0x0CF30000UL) ) and now the whole thing works great....&lt;/p&gt;
&lt;p&gt;Although I should be happy right now, I am a little confused. Can you explain this strange behavior?&lt;/p&gt;
&lt;p&gt;Thank you for your assistance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174656?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 18:49:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca4f1b20-f762-481e-99a7-09779b1b29b8</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suspect some race condition in the code, do you experience the same if you disable EasyDMA, example:&lt;br /&gt;#define TWI0_USE_EASY_DMA 0&lt;/p&gt;
&lt;p&gt;OR&lt;/p&gt;
&lt;p&gt;Have you tried to operate the twi driver in blocking mode? In that case there is no callback event handler, and instead&amp;nbsp;nrf_drv_twi_tx() and&amp;nbsp;nrf_drv_twi_rx() will return when transfer is complete (you can skip the while(nrf_drv_twi_is_busy())-loops). This can be done by calling&amp;nbsp;nrf_drv_twi_init() with NULL as event_handler, e.g:&amp;nbsp;nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL);&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174335?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 15:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73fd02b2-35e9-4058-a579-e80ab8a57b5b</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;I was based on that example to do this.The nRF SDK I use is 15.2.0.&lt;/p&gt;
&lt;p&gt;I partially solved the issue by increasing the TWI speed to 400kHz.&lt;/p&gt;
&lt;p&gt;I say partially because now when I fetch data from the sensor continuously once per second at some point the SDA line stalls at the point where data are brought back from the sensor. &lt;/p&gt;
&lt;p&gt;This is depicted in the following images taken from the logic analyzer.&lt;/p&gt;
&lt;p&gt;The first image shows the IMU accel/gyro data transfers and at the right end of the image the SDA stall is shown&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2275.Capture2.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;The second&amp;nbsp; image shows one of these IMU accel/gyro data transfers and again at the right end of the image the SDA stall is shown&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2625.Capture.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What do you think it might cause it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Correct order of nrf_drv_twi commands</title><link>https://devzone.nordicsemi.com/thread/174297?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 14:13:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:339810d4-edb6-4915-a054-580575569115</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not sure which SDK you are using, but make sure you are using the lates e.g. SDKv15.3.&lt;/p&gt;
&lt;p&gt;I suggest you start with the&amp;nbsp;\examples\peripheral\twi_sensor as reference, and you can find that it uses a&amp;nbsp;m_xfer_done flag between the&amp;nbsp;twi_handler() and main() to be informed about when the preceding twi transfer is finished and ready to start the next.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>