<?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>I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77286/i2c-slave-with-twi-not-sending-all-data</link><description>We have an nRF52840 setup as a slave to communicate with a motor controller. I connected a logic analyzer to the lines to confirm the data being sent across. There are 18 data points that get sent on a read request. I hard coded the values to be sent</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Jul 2021 11:38:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77286/i2c-slave-with-twi-not-sending-all-data" /><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/321328?ContentTypeID=1</link><pubDate>Thu, 22 Jul 2021 11:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:827f2123-5674-4401-8588-0f8d23e2ca2e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m glad you got it working and I&amp;#39;m happy to help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/320958?ContentTypeID=1</link><pubDate>Tue, 20 Jul 2021 14:37:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d13dde78-6fdb-4981-8f88-fa05ab1ef085</guid><dc:creator>brandonv</dc:creator><description>&lt;p&gt;We needed to send the full array at one time instead of each byte individually. The tx_prepare is preparing the full 18 bytes to send at one time. We got it working now. Thank you for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/320684?ContentTypeID=1</link><pubDate>Mon, 19 Jul 2021 12:16:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c506244c-ba5a-40c8-9b9a-82405cfaa399</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;For ncs v1.6.0, the TWIM’s prj.conf file needs to be modified.&lt;/p&gt;
&lt;p&gt;Replace&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;CONFIG_SPI_1=n&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;with&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;CONFIG_NRFX_SPI1=n&lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;in proj.conf&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/320393?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 09:48:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c1cc87d-3192-4af5-91f5-03a6a80a8493</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try to remove the printk&amp;#39;s between each&amp;nbsp;nrfx_twis_tx_prepare(), also sizeof(zero) will send &amp;quot;\0&amp;quot;.&lt;/p&gt;
&lt;p&gt;A colleague (&lt;a href="https://devzone.nordicsemi.com/members/jeff_2d00_s"&gt;Jeff4BLE&lt;/a&gt;) created a project to demonstrate how to use an I2C Slave in NCS,&amp;nbsp;&lt;span style="font-family:inherit;"&gt;check it out here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/blinky_2D00_twim.zip"&gt;devzone.nordicsemi.com/.../blinky_2D00_twim.zip&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/blinky_2D00_twis.zip"&gt;devzone.nordicsemi.com/.../blinky_2D00_twis.zip&lt;/a&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;This has been tested with ncs v1.5.1. Extract the attached to \zephyr\samples\basic\blinky-twis&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;To test the attached, use two nrf52840dks. One as a Master and the other as a Slave.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Connect master’s P0.31 (CLK) to the Slaves P0.27.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Connect master’s P0.20 (SDA) to the slave’s P0.26.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Be sure that the DK’s share a common ground.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Connec the virtual com port on each DK.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;To run the tests, first reset the slave and then the master.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;TWIM can be built with two configurations. This is selected by changing the value of TWI_LOOPBACK in the main.c (Line 40).&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;#define TWI_LOOKBACK false.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The master repeatedly sends “From TWIM” to the slave.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The slave cycles through a large message that is sent over multiple read requests from the master.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x320/__key/communityserver-discussions-components-files/4/pastedimage1626428521797v3.png" /&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;#define TWI_LOOPBACK true&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The master will first a message “Begin Loopback.” Subsequent messages will be the last message received from the slave.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x320/__key/communityserver-discussions-components-files/4/pastedimage1626428658452v6.png" /&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Some few notes:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;It’s not a good idea to leave the printk in the twis_event_handler.&lt;/li&gt;
&lt;li&gt;The&amp;nbsp;nrfx_twis_init return values are not thoroughly looked into&lt;/li&gt;
&lt;li&gt;In blinky-twis’s twis_event_handler, if printk(&amp;quot;\nTWIS READ ERROR\n&amp;quot;); and printk(&amp;quot;\nTWIS GENERAL ERROR\n&amp;quot;); are uncommented, these messages are printed. This would seem to indicate that the program is getting TWIS_EVT_READ_ERRORS and TWIS_EVT_GENERAL_ERRORs. I have has time to track this down. However, the program appears to work as expected. So it’s not a high priority. This may be related to 1.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/319672?ContentTypeID=1</link><pubDate>Mon, 12 Jul 2021 17:38:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a41d175-1e66-4501-a3b0-2994bfe3d8d0</guid><dc:creator>brandonv</dc:creator><description>&lt;p&gt;Simon,&lt;/p&gt;
&lt;p&gt;The two appear to have similar function calls to&amp;nbsp;nrfx_twis_tx_prepare() to populate the buffer for transmission.&lt;/p&gt;
&lt;p&gt;I am currently calling this function in successive order to transmit the total data. Should there be something in between each call?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Slave with TWI not sending all data</title><link>https://devzone.nordicsemi.com/thread/319484?ContentTypeID=1</link><pubDate>Sun, 11 Jul 2021 11:23:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cec89fcc-7e6b-47b3-a284-5d71787b4afc</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Sorry for the delay on this.&lt;/p&gt;
&lt;p&gt;Have you seen the sample&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Ftwi_master_with_twis_slave_example.html&amp;amp;cp=8_1_4_6_45"&gt;&lt;span&gt;TWIS Slave and TWI Master Mode Drivers Example&lt;/span&gt;&lt;/a&gt;&amp;nbsp;from the nRF5 SDK? It uses the nrf_drv API instead of the NRFX api, but they should be fairly similar. Looking at that sample, and specifically the file&amp;nbsp;examples/peripheral/twi_master_with_twis_slave/eeprom_simulator.c, you may get an idea how to implement an I2C slave.&lt;/p&gt;
&lt;p&gt;If this didn&amp;#39;t help, I will investigate your issue more thoroughly.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>