<?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>Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53643/problems-using-twi-in-slave-mode</link><description>Hello, 
 I am using a development board pro nrf52840 mini from Sparkfun. 
 I&amp;#39;m trying to use the TWI peripheral on nrf52840 to communicate with an external device (another microcontroller). The nrf52840 is supposed to be a slave on TWI and the external</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Nov 2019 21:56:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53643/problems-using-twi-in-slave-mode" /><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/218374?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2019 21:56:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:004041dc-3dfd-4453-9929-ad1283ebc92b</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Use &lt;a href="https://www.freewarefiles.com/Termite_program_61676.html"&gt;Termite&lt;/a&gt;&amp;nbsp;and choose the following parameters:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-78e4ce1801db4da8b329431656f0f15a/pastedimage1572902573945v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;The nRF52840 DK&amp;nbsp;comes with&amp;nbsp;an &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf52840_dk%2FUG%2Fnrf52840_DK%2Fif_mcu.html&amp;amp;cp=3_0_4_6"&gt;interface MCU&lt;/a&gt;&lt;span&gt;&amp;nbsp;that features a USB to UART Bridge, however, I don&amp;#39;t think the nRF52840 Sparkfun board has that. Then you can configure a UART peripheral instance and use a cable like &lt;a href="https://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232RG_CABLES.pdf"&gt;this&lt;/a&gt;&amp;nbsp;to see the logging. UART logging should be enabled in the file&amp;nbsp;&lt;em&gt;sdk_config.h&lt;/em&gt;&amp;nbsp;of the project I provided&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I used the nRF52832 DK, I haven&amp;#39;t tested it on the nRF52840 DK, or Sparkfun nRF52840 mini for that matter. However, I think it should work on those boards as well.&lt;/p&gt;
&lt;p&gt;It is strange that you don&amp;#39;t see any output on the Sparkfun board. Maybe it&amp;#39;s broken? Could you try to use some other GPIO pins for&amp;nbsp;&lt;span&gt;TWI_SCL/SDA_M&amp;nbsp;and EEPROM_SIM_SCL/SDA_S&amp;nbsp;and see if that works? You could also consider buying the nRF52840 DK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/218345?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2019 17:23:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:013786e6-8ba6-4117-b638-7f49e19cbf6e</guid><dc:creator>BMG</dc:creator><description>&lt;p&gt;Thank you very much, but I tried with your first example (to shorten the pins of the same board) and SCL and SDA lines are down all the time. I analyzed RESET pin and it&amp;#39;s ok, even if the blue led is blinking continuously (is this blink normal?).&lt;/p&gt;
&lt;p&gt;Which soft are you using to see NRF_LOG messages?&lt;/p&gt;
&lt;p&gt;Are you using sparkfun nrf52840 mini or another board?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/218010?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 16:21:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56425636-4817-462d-aad4-77062952c4b3</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I was able to make this work. First I added the following lines of code to the&amp;nbsp;&lt;em&gt;twi_master_with_twis_slave&lt;/em&gt; in the &lt;em&gt;main()&lt;/em&gt; function&amp;nbsp;(right before &lt;em&gt;while(1)&lt;/em&gt;):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi_master, EEPROM_SIM_ADDR, test_buff, IN_LINE_PRINT_CNT);
if(err_code == NRF_SUCCESS)
{
    NRF_LOG_RAW_INFO(&amp;quot;TWI device detected \n&amp;quot;);
} else{
    NRF_LOG_RAW_INFO(&amp;quot;TWI device NOT detected \n&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then I shorted the following pins:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;TWI_SCL_M (P0.03) - EEPROM_SIM_SCL_S (&lt;span&gt;P0.&lt;/span&gt;31)&lt;/li&gt;
&lt;li&gt;TWI_SDA_M (&lt;span&gt;P0.0&lt;/span&gt;4) - EEPROM_SIM_SDA_S (&lt;span&gt;P0.&lt;/span&gt;30)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I built and flashed the example, and observed that &amp;quot;TWI device detected&amp;quot; appeared in the terminal.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Then I did the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Flashed the modified&amp;nbsp;&lt;em&gt;twi_master_with_twis_slave&lt;/em&gt;&lt;span&gt;&amp;nbsp;example onto two different nRF52832 DK&amp;#39;s&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Made sure the devices had common ground by connection GND from one of the boards to GND on the other board&lt;/li&gt;
&lt;li&gt;Decide which board should be the master and which board should be the slave&amp;nbsp;(doesn&amp;#39;t matter which board you choose to be slave/master)&lt;/li&gt;
&lt;li&gt;Connect&amp;nbsp;&lt;span&gt;P0.03 on the&amp;nbsp;master to P0.31 on the slave&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Connect P0.04 on the master to P0.30 on the slave&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Reset the slave board first and the master board after (the order is important)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Check that &amp;quot;TWI device detected&amp;quot; appeared in the terminal of the master board&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;I checked the signals in a logic analyzer as well and saw that the address was ACKed (If you discard the last binary value from 0d161, you will get 0x50=EEPROM_SIM_ADDR):&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-78e4ce1801db4da8b329431656f0f15a/pastedimage1572625203792v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is the modified project in zipped format:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-78e4ce1801db4da8b329431656f0f15a/twi_5F00_master_5F00_with_5F00_twis_5F00_slave.zip"&gt;devzone.nordicsemi.com/.../twi_5F00_master_5F00_with_5F00_twis_5F00_slave.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/217772?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 13:19:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac97409c-0813-495f-9f1b-c5e178ac3b72</guid><dc:creator>BMG</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/salae.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The search is done between [0x00, 0xFA] and for all, the result is NAK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/217757?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 12:22:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0643dc7-0b2e-436d-b4b6-81cbe6cc49ff</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Do you have a logic analyzer? If you have, attach it to the SDA and SCL lines and provide the result here. If you don&amp;#39;t have one, I will try to see if I can do it myself.&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><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/217585?ContentTypeID=1</link><pubDate>Wed, 30 Oct 2019 15:21:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aced0cd5-0f2b-4768-8943-86860d2366f5</guid><dc:creator>BMG</dc:creator><description>&lt;p&gt;Thank you for your answer, but unfortunately the nrf52840 (slave) does not respond to the external device (master).&lt;/p&gt;
&lt;p&gt;I made your changes, but no result. I also modified the&amp;nbsp;\nRF5\nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave\sparkfun_nrf52840_mini\blank\config\sdk_config.h file. The changes I&amp;#39;ve done are the following:&lt;/p&gt;
&lt;p&gt;#define NRFX_TWIM_ENABLED 0&lt;br /&gt;#define NRFX_TWIS1_ENABLED 1&lt;br /&gt;#define NRFX_TWI1_ENABLED 1&lt;/p&gt;
&lt;p&gt;The only thing modified in&amp;nbsp;\nRF5\nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave\main.c is to comment the following lines, because I want nrf52840 to be the slave :&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;//&amp;nbsp;err_code&amp;nbsp;=&amp;nbsp;twi_master_init();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;//&amp;nbsp;APP_ERROR_CHECK(err_code);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Have these&amp;nbsp;changes any impact on the behaviour of the slave?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;How can I find out the TWI address of the nrf52840? The device does not respond if I scan it in the interval [1,127].&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Moreover, if I run the original example&amp;nbsp;\nRF5\nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave, I observed that a periodic reset is issued. I think it&amp;#39;s a period reset because the blue middle led is blinking on the board.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thank you.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems using TWI in slave mode</title><link>https://devzone.nordicsemi.com/thread/217213?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 21:15:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:839826a4-e967-4e7e-9634-9b5bd6e5d0bb</guid><dc:creator>Simon</dc:creator><description>&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;In this example, I do not know which instance of TWIS is activated and I do not find in the documentation which pins correspond to which TWIS instance.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The TWIS instance 1 is used. Take a look at the file&amp;nbsp;nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave\eeprom_simulator.c on line 91&lt;/li&gt;
&lt;li&gt;The slave SCL corresponds to pin 31 and the slave SDA corresponds to pin 30. Take a look at the file&amp;nbsp;nRF5_SDK_15.3.0_59ac345\examples\peripheral\twi_master_with_twis_slave\config.h on line 71.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;Can you, please, tell me how can I modify this example code so the slave answers or can you provide an example to startup the slave and to receive data?&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Study the file&amp;nbsp;&lt;span&gt;eeprom_simulator.c and try to understand how it works, then modify it according to your slave. If you have any particular questions, please ask.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You could also&amp;nbsp;follow the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Ftwi_master_with_twis_slave_example.html&amp;amp;cp=5_5_0_4_6_45"&gt;guide on the infocenter&lt;/a&gt;, as an initial step to get an understanding of how it works.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>