<?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>Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25842/why-can-not-read-twi-data-twi-interfacing-with-rtc-ds1307</link><description>Why can not read twi data ? at nrf52832 chip....
but Read well in Arduino.... 
 twi interfacing with RTC DS1307.... 
 please give me some hint..... 
 
 
 nrf_drv_config.h 
 #define TWI0_ENABLED 1
#define TWI1_ENABLED 1 
 
 
 define 
 #define</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Oct 2017 23:45:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25842/why-can-not-read-twi-data-twi-interfacing-with-rtc-ds1307" /><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101789?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 23:45:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dc72f27-9aca-4298-a98c-5aa06f0e13e3</guid><dc:creator>chchoi</dc:creator><description>&lt;p&gt;Thank you for your response ,  thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101790?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 13:54:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e0280be-ce90-4596-a0a1-34769d201d08</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;We don&amp;#39;t have examples or code for that around here, but if you google something like &amp;quot;dS1307 c library&amp;quot; i&amp;#39;m sure you will find some tips.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101788?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 07:57:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f88a2f78-5dfd-474a-aaf6-7df8adea6b8e</guid><dc:creator>chchoi</dc:creator><description>&lt;p&gt;I have finally read the data.&lt;/p&gt;
&lt;p&gt;DS1337 Get Time.
twi_i2c_read_err 0,  0  ,[00]&lt;/p&gt;
&lt;p&gt;0 = 0x38&lt;br /&gt;
1 = 0x42&lt;br /&gt;
2 = 0x3A&lt;br /&gt;
3 = 0x88&lt;br /&gt;
4 = 0x23&lt;br /&gt;
5 = 0x47&lt;br /&gt;
6 = 0x17&lt;br /&gt;
7 = 0x70&lt;br /&gt;
8 = 0x7E&lt;br /&gt;
9 = 0xF7&lt;br /&gt;
10 = 0xE9&lt;br /&gt;
11 = 0x23&lt;br /&gt;
12 = 0xC1&lt;br /&gt;
13 = 0x78&lt;br /&gt;
14 = 0x67&lt;br /&gt;
15 = 0x37&lt;/p&gt;
&lt;p&gt;The reason I could not read it was because I read sda scl using only battery power.
I can read the data after connecting 3.2v power to VCC, GND in DS1307.&lt;/p&gt;
&lt;p&gt;Thank you for your response.
I would appreciate it if you could give me a place to refer to how to convert from buffer data to date and time data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101793?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 07:02:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6388e036-caaa-4dee-a4e0-b9a1d9a0f32b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Is xfer_completed  declared volatile? &lt;a href="https://barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword"&gt;THis could be important&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Can you post your entire code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101792?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 00:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cab23145-4844-4673-ab8c-48c0d856637c</guid><dc:creator>chchoi</dc:creator><description>&lt;p&gt;Thank you for your help.&lt;/p&gt;
&lt;p&gt;I tried it but it did not work.&lt;/p&gt;
&lt;hr /&gt;
&lt;pre&gt;&lt;code&gt;switch(p_event-&amp;gt;type)
{
	case NRF_DRV_TWI_EVT_DONE:				

		if ( (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_RX) || (p_event-&amp;gt;xfer_desc.type == NRF_DRV_TWI_XFER_TX))
		{
			xfer_completed = true;
			printf(&amp;quot;\n\r twi_handler complete .\r\n&amp;quot;);
		}		

		else
		{
			xfer_completed = false;
		}

		break;	

	default:
		break;
}

//	do
//   {
//       __WFE();
//  }while(xfer_completed == false);

err_code = nrf_drv_twi_rx(&amp;amp;m_twi_ds1307, DS1307_ADDR, r_buf, sizeof(r_buf));		
//	 xfer_completed = false;
nrf_delay_ms(10);
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;There was no effect if enough delay was given.&lt;/p&gt;
&lt;p&gt;What are the elements I have not thought of yet?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why can not  read  twi data ?      twi interfacing with RTC DS1307....</title><link>https://devzone.nordicsemi.com/thread/101791?ContentTypeID=1</link><pubDate>Wed, 11 Oct 2017 08:57:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ab6cbac-56da-441d-ba8b-eec638216ef3</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Since you are using a TWI handler function, you are using the TWI driver in the so called &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/hardware_driver_twi.html?cp=4_0_0_2_16_1#hardware_driver_twi_basic"&gt;&amp;quot;non-blocking&amp;quot; mode&lt;/a&gt;. That means that nrf_drv_twi_rx() returns immediately, but the TWI reading is actually not completed before later. So since you initiate r_buf[] to all zeros, and you haven&amp;#39;t actually received any data yet when you call printf(), all you see is zeros.&lt;/p&gt;
&lt;p&gt;You can easily solve this problem by using the driver in blocking mode, or use a flag in your TWI handler that and wait for that flag to be set before you read out your data.&lt;/p&gt;
&lt;p&gt;In your post you don&amp;#39;t show any code that tells the DS1307 what registers you want read either. I assume you have it in your application? Your code should look something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_twi_tx(&amp;amp;m_twi_ds1307, DS1307_ADDR, address_that_you_want_to_read, 1);
APP_ERROR_CHECK(err_code);

// Use blocking mode or wait in a while(!tx_flag) loop here

uint8_t   r_buf[16]={0,};
err_code = nrf_drv_twi_rx(&amp;amp;m_twi_ds1307, DS1307_ADDR, r_buf, sizeof(r_buf));
APP_ERROR_CHECK(err_code);

// Use blocking mode or wait in a while(!rx_flag) loop here

for (uint32_t i = 0; i &amp;lt; 16; i++)
{
    printf(&amp;quot;%d = 0x%02X \n&amp;quot;,i, r_buf[i] );  
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also, make sure to try &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/twi_scanner_example.html?cp=4_0_0_4_5_36"&gt;this example&lt;/a&gt; to confirm that you have wired everything correctly and use the right address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>