<?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>nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom</link><description>nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM 
 
 Hi, this is vadivelan 
 I am working on a task like interfacing external EEPROM memory with nrf52dk board I used TWI scanner example for that then I interfaced with external EEPROM</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 31 May 2021 12:58:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom" /><item><title>RE: nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/thread/312640?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 12:58:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b31a3127-1e02-4498-8b6e-b80e334567d1</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="0_velan_1"]&lt;p&gt;&lt;span&gt;i passed data to sample_dat=&amp;#39;1&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code= nrf_drv_twi_tx(&amp;amp;m_twi,0x50,&amp;amp;sample_dat,sizeof(sample_dat),0);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;for that&amp;nbsp; here&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi,&amp;nbsp;0x51, &amp;amp;sample_data, sizeof(sample_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in the sample_data buffer variable, i want data &amp;#39;1&amp;#39; from EEPROM memory but got 255 in decimal value&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have doubt that I&amp;#39;m doing correct or not...&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;It might be beneficial for you to have a look at&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/twi_master_with_twis_slave_example.html"&gt;the TWI master mode example&lt;/a&gt;, it demonstrates how to interface a simulated EEPROM module. You there see how you could go about implementing EEPROM interface. It might be easier for you to start out from this example, since the scanner is able to find the device on the bus successfully. Exactly which EEPROM module are you working with by the way, and how long times does it require in between transfers?&lt;/p&gt;
[quote user="0_velan_1"]&lt;blockquote&gt;&lt;div&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom/312107#312107"&gt;Karl Ylvisaker said:&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Do you have access to a logical analyzer?&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;
&lt;p&gt;&lt;span&gt;no&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;That is unfortunate - developing and debugging serial interfaces are tenfold easier with a logical analyzer, for future reference. Can you show me what you logs says when you run your program?&lt;/p&gt;
[quote user="0_velan_1"]&lt;p&gt;&lt;span&gt;that issue resolved but I got from here&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi,address, &amp;amp;sample_data, sizeof(sample_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in this function return value that time i got 33281&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;This does not correspond to any of the error codes this function can return. I am not sure I understand the structure of the code you have pasted earlier, there was some issues with the formatting in your previous comment. Is the last code block following immediately after the logging if&amp;#39;s, or does it come in somewhere else? There is a random bullet point present, and some odd indentation.&lt;br /&gt;Please use the Insert -&amp;gt; Code option when sharing code, and make sure that the code is properly readable before submitting - this makes it easier for others to read, debug, and help you.&lt;/p&gt;
[quote user="Karl Ylvisaker"]I am not sure that I understand your intentions with the if-statements containing logging happening after the call to&amp;nbsp;&lt;span&gt;nrf_drv_twi_tx - are you here implementing your own error checking?&lt;/span&gt;[/quote]
&lt;p&gt;Please answer this question. I would recommend that you instead make use of the APP_ERROR_CHECK, for future reference. Please do this, and add APP_ERROR_CHECKs to all returned error codes from SDK functions.&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/thread/312146?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 13:49:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:986b955e-06cc-4e3e-8393-741604355a0b</guid><dc:creator>0_velan_1</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom/312107#312107"]What value were you expecting to read from this particular memory location?[/quote]
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom/312107#312107"]What value were you expecting to read from this particular memory location?[/quote]
&lt;p&gt;&lt;span&gt;i passed data to sample_dat=&amp;#39;1&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code= nrf_drv_twi_tx(&amp;amp;m_twi,0x50,&amp;amp;sample_dat,sizeof(sample_dat),0);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;for that&amp;nbsp; here&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi,&amp;nbsp;0x51, &amp;amp;sample_data, sizeof(sample_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in the sample_data buffer variable, i want data &amp;#39;1&amp;#39; from EEPROM memory but got 255 in decimal value&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have doubt that I&amp;#39;m doing correct or not...&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom/312107#312107"]Do you have access to a logical analyzer?[/quote]
&lt;p&gt;&lt;span&gt;no&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/75679/nrf52-dk-board-twi-scanning-example-interfacing-with-external-eeprom/312107#312107"]Could you also clarify exactly where the error code was read out to be 33281?&lt;br /&gt;[/quote]
&lt;p&gt;&lt;span&gt;that issue resolved but I got from here&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_rx(&amp;amp;m_twi,address, &amp;amp;sample_data, sizeof(sample_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in this function return value that time i got 33281&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;here there is loop is address 1 to 127 address scanning on that for example address 1&amp;nbsp; scanning for that particular address no device found means this value=33281 that function returning ..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&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;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/thread/312107?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 13:01:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e8392f5-b387-49d6-8602-19079a02b853</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="0_velan_1"]thanks for the reply[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="0_velan_1"]there is an issue in connection before I connected directly 5v EEPROM ic but when i changed 5v to 3.3v after that particular device address found&amp;nbsp;[/quote]
&lt;p&gt;I am glad to hear that you are now able to find the address of the device! I must advice you to always check the proper VDD level of an IC before connecting power to it - many IC&amp;#39;s, including the nRF52 family - may be damaged and/or fried if you connect 5 V directly to its VDD bus. The damage may not always be obvious, and so it could cost you many hours of debugging to detect and identify the issue down the road, which can be very frustrating. Please make sure to always check this in the future.&lt;/p&gt;
&lt;p&gt;I am not sure that I understand your intentions with the if-statements containing logging happening after the call to&amp;nbsp;&lt;span&gt;nrf_drv_twi_tx - are you here implementing your own error checking?&lt;br /&gt;If so, I would advice you to make sure DEBUG is enabled - like I mentioned in my previous comment - and instead just pass the error code to an APP_ERROR_CHECK.&lt;/span&gt;&lt;/p&gt;
[quote user="0_velan_1"]but now i send data=&amp;#39;1&amp;#39; to EEPROM address 0x50 there is no issue on that but try to receive data with rx() function&amp;nbsp;getting value in buffe data is in int value=255&amp;nbsp;[/quote]
&lt;p&gt;What value were you expecting to read from this particular memory location?&lt;br /&gt;Do you have access to a logical analyzer?&lt;br /&gt;It would help a lot to be able to see what is happening on the lines here.&lt;br /&gt;&lt;br /&gt;Could you also clarify exactly where the error code was read out to be 33281?&lt;br /&gt;&lt;br /&gt;For future reference, please always use the Insert -&amp;gt; Code option when sharing code here on DevZone, this drastically increases the readability.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/thread/312088?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 12:28:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c311abf7-4727-4a65-b861-9b0df8c70216</guid><dc:creator>0_velan_1</dc:creator><description>&lt;p&gt;hi Karl Ylvisakar thanks for the reply&lt;/p&gt;
&lt;p&gt;there is an issue in connection before I connected directly 5v EEPROM ic but when i changed 5v to 3.3v after that particular device address found&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;but now i send data=&amp;#39;1&amp;#39; to EEPROM address 0x50 there is no issue on that but try to receive data with rx() function&amp;nbsp;getting value in buffe data is in int value=255&amp;nbsp;&lt;/p&gt;
&lt;p&gt;what i am making mistake help me&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;/* TWI instance ID. */&lt;br /&gt;#if TWI0_ENABLED&lt;br /&gt;#define TWI_INSTANCE_ID 0&lt;br /&gt;#elif TWI1_ENABLED&lt;br /&gt;#define TWI_INSTANCE_ID 1&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;/* Number of possible TWI addresses. */&lt;br /&gt; #define TWI_ADDRESSES 127&lt;/p&gt;
&lt;p&gt;/* TWI instance. */&lt;br /&gt;static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;/**&lt;br /&gt; * @brief TWI initialization.&lt;br /&gt; */&lt;br /&gt;void twi_init (void)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;/p&gt;
&lt;p&gt;const nrf_drv_twi_config_t twi_config = {&lt;br /&gt; .scl = ARDUINO_SCL_PIN, &lt;br /&gt; // .scl_pull = NRF_GPIO_PIN_PULLUP,&lt;br /&gt; .sda = ARDUINO_SDA_PIN,&lt;br /&gt; //.sda_pull = NRF_GPIO_PIN_PULLUP&lt;br /&gt; .frequency = NRF_DRV_TWI_FREQ_400K,&lt;br /&gt; .interrupt_priority = APP_IRQ_PRIORITY_HIGH,&lt;br /&gt; .clear_bus_init = false&lt;br /&gt; };&lt;/p&gt;
&lt;p&gt;err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, NULL, NULL);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;nrf_drv_twi_enable(&amp;amp;m_twi);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;/**&lt;br /&gt; * @brief Function for main application entry.&lt;br /&gt; */&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; uint8_t address;&lt;br /&gt; uint8_t sample_data;&lt;br /&gt; uint8_t sample_dat =&amp;#39;1&amp;#39;;&lt;br /&gt; bool detected_device = false;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; APP_ERROR_CHECK(NRF_LOG_INIT(NULL));&lt;br /&gt; NRF_LOG_DEFAULT_BACKENDS_INIT();&lt;/p&gt;
&lt;p&gt;NRF_LOG_INFO(&amp;quot;TWI scanner started.&amp;quot;);&lt;br /&gt; NRF_LOG_FLUSH();&lt;br /&gt; twi_init();&lt;br /&gt; bsp_board_init(BSP_INIT_LEDS);&lt;br /&gt; bsp_board_init(BSP_INIT_BUTTONS);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; &lt;br /&gt; // nrf_delay_ms(50);&lt;/p&gt;
&lt;p&gt;err_code= nrf_drv_twi_tx(&amp;amp;m_twi,0x50,&amp;amp;sample_dat,sizeof(sample_dat),0);&lt;br /&gt;printf(&amp;quot;error_code=%d&amp;quot;,err_code);&lt;br /&gt; if (err_code == NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot;0&amp;quot;);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;if (err_code == NRF_ERROR_INVALID_ADDR)&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot;1&amp;quot;);&lt;br /&gt; }&lt;br /&gt; if (err_code ==NRF_ERROR_INTERNAL)&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot;2&amp;quot;);&lt;br /&gt; }&lt;br /&gt; if (err_code == NRF_ERROR_DRV_TWI_ERR_OVERRUN )&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot;3&amp;quot;);&lt;br /&gt; }&lt;br /&gt; if (err_code ==NRF_ERROR_DRV_TWI_ERR_ANACK )&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot; 4&amp;quot;);&lt;br /&gt; }&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;br /&gt; &lt;br /&gt; for (address = 0; address &amp;lt;= TWI_ADDRESSES; address++)&lt;br /&gt; {&lt;br /&gt; nrf_delay_ms(50);&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi,address, &amp;amp;sample_data, sizeof(sample_data));&lt;br /&gt; &lt;br /&gt; if (err_code == NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; detected_device = true;&lt;br /&gt; NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);&lt;br /&gt; &lt;br /&gt;printf(&amp;quot; sample data=%c\n\r&amp;quot;, sample_data); //255 &lt;br /&gt; printf(&amp;quot;TWI device detected at address 0x%x.&amp;quot;, address);&lt;br /&gt; }&lt;br /&gt; NRF_LOG_FLUSH();&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; if (!detected_device)&lt;br /&gt; {&lt;br /&gt; NRF_LOG_INFO(&amp;quot;No device was found.&amp;quot;);&lt;br /&gt; NRF_LOG_FLUSH();&lt;br /&gt; }&lt;br /&gt;while(1)&lt;br /&gt; {&lt;br /&gt; for (int i = 0; i &amp;lt; LEDS_NUMBER; i++)&lt;br /&gt; {&lt;br /&gt; bsp_board_led_invert(i);&lt;br /&gt; nrf_delay_ms(500);&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/** @} */&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52 dk board TWI SCANNING EXAMPLE INTERFACING WITH EXTERNAL EEPROM</title><link>https://devzone.nordicsemi.com/thread/312079?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 12:19:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c79ac2e-cba4-4ff7-b4bd-f6642e1ee975</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Vedivelan,&lt;/p&gt;
[quote user=""]I used TWI scanner example for that then I interfaced with external EEPROM but it&amp;#39;s showing on terminal &amp;quot;no devices was found &amp;quot;[/quote]
&lt;p&gt;This makes me suspect that there is an issue with your connection between the nRF and the EEPROM. Could you show some schematics of how you have wired the two together?&lt;/p&gt;
[quote user=""]I checked err_code value is=33281&amp;nbsp;receiving&amp;nbsp;[/quote]
&lt;p&gt;Could you show me the entire code snippet for the function or section of code leading up to this value?&lt;br /&gt;&lt;br /&gt;Please also make sure that you have DEBUG defined in your preprocessor defines, like shown in the included image:&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/0714.enabling_5F00_debug_5F00_SES.PNG" /&gt;&lt;br /&gt;This will make the logger print a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.&lt;br /&gt;&lt;br /&gt;Please add DEBUG to your preprocessor defines, and let me know what the error message in your log says when this error is encountered.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>