<?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>nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55764/nrf52840-twi-with-eeprom-using-registers-directly</link><description>I am trying to interface I2C EEPROM (AT24C512) with nrf52840 and I am directly writing to and reading from the registers mentioned in the datasheet. I am seeing the i2c waveforms on DSO and I think I am getting the start pulse correctly but not the further</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 25 Dec 2019 15:45:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55764/nrf52840-twi-with-eeprom-using-registers-directly" /><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226845?ContentTypeID=1</link><pubDate>Wed, 25 Dec 2019 15:45:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0268c006-3de9-4531-bd64-3af4ed49ea6f</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;SES does not support C++ sorry. &amp;nbsp;Can&amp;#39;t be used with SES but you can use CrossWorks with external GCC compiler or IAR or Eclipse. See README.md of the repo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226821?ContentTypeID=1</link><pubDate>Wed, 25 Dec 2019 08:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d48c4d36-b1db-4289-b98e-1735f147a213</guid><dc:creator>PoojaK</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I tried a lot but the .cpp file and project is not working in my ses.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And I am still stuck with my i2c.&lt;/p&gt;
&lt;p&gt;I really need help &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226576?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 13:31:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27d1c831-2773-4189-8076-961ad92540dd</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;This code here works with any Eeprom&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/src/seep_impl.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/src/seep_impl.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;better i2c&amp;nbsp;implementation here&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/i2c_nrf5x.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/i2c_nrf5x.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226567?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 12:58:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6828ad5d-afd6-4134-aa13-c7aa2586ed3a</guid><dc:creator>PoojaK</dc:creator><description>&lt;p&gt;I tried the code you have sent. I changed the code as per my device address and i2c pins.But I am not getting any data on the dso. Also as per the EEPROM I need to send Device address which is 8 bit then Start Address which is 16 bit and then the data to be transmitted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I made the following changes&lt;pre class="ui-code" data-mode="text"&gt;void i2c_write(uint8_t addr, uint8_t data1)
{
  uint8_t tx_buf[3];
  NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STOP_Msk;

  tx_buf[0] = 0x00 ; //(addr&amp;amp;&amp;amp;0x000000FF);
  tx_buf[1] = 0x01 ; //((addr&amp;amp;&amp;amp;0x0000FF00)&amp;gt;&amp;gt;8);
  tx_buf[2] = 0x55;

  NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
  NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

  NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
  NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
  while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But I cannot see any data.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also I tried writing my own routine in this manner which is working but the data sequence is getting mismatched&lt;pre class="ui-code" data-mode="text"&gt; while (1)
      {
        TimCnt = 0 ;
        NRF_TWI0-&amp;gt;ADDRESS = 0x50 ;//(EEWriteAddress) ;//&amp;gt;&amp;gt;1) ; // EEWriteAddress ;
        NRF_TWI0-&amp;gt;TXD = 0x55 ;//(u32startAddr &amp;amp; 0x000000FF);
        TimCnt = 0 ; 
        NRF_TWI0-&amp;gt;EVENTS_STOPPED = 0 ; 
        NRF_TWI0-&amp;gt;TASKS_STARTTX = 1 ;
        while((NRF_TWI0-&amp;gt;EVENTS_TXDSENT) == 0)
        {
         
        }
        NRF_TWI0-&amp;gt;TXD = 0x0f ;
        while((NRF_TWI0-&amp;gt;EVENTS_TXDSENT) == 0)
        {
         
        }
        NRF_TWI0-&amp;gt;TXD = 0x66 ;
        while((NRF_TWI0-&amp;gt;EVENTS_TXDSENT) == 0)
        {
         
        }
        NRF_TWI0-&amp;gt;TASKS_STOP = 1 ;
        while (NRF_TWI0-&amp;gt;EVENTS_STOPPED == 0)
        {
        }
        TimCnt = 0 ; 
        while(TimCnt &amp;lt; 200) ;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As in I am getting Start Pulse-&amp;gt;0x50-&amp;gt;0x0F-&amp;gt;0x66-&amp;gt;0x55 as per the given code.&lt;/p&gt;
&lt;p&gt;One more issue is that when I am sending the stop condition I am getting neither of the above.&lt;/p&gt;
&lt;p&gt;Just Start-&amp;gt;0x50-&amp;gt;Stop&lt;/p&gt;
&lt;p&gt;Please help me out here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226415?ContentTypeID=1</link><pubDate>Thu, 19 Dec 2019 15:01:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85ac1834-971b-4073-afc5-967f4d0df19e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I think you are doing it wrong.&amp;nbsp;Please study the TWI peripheral in the datasheet. The address in&amp;nbsp;NRF_TWI0-&amp;gt;ADDRESS is not the address in the EEPROM you want to read, but it&amp;#39;s the address of the EEPROM it self. It&amp;#39;s the A0 A1 that you need to hardwire on your EEPROM (so it&amp;#39;s either 0,1,2 or 3)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I attached here a bare metal code to do some read or write with a TWI address 0x2A:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;nrf.h&amp;gt;

#define DEVICE_ADDRESS   (0x2A)
#define PIN_SCL        (3)
#define PIN_SDA        (4)
uint8_t tx_buf[1];
uint8_t rx_buf[3];
 
void i2c_write(uint8_t addr, uint8_t data)
{
  uint8_t tx_buf[2];
  NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STOP_Msk;

  tx_buf[0] = addr;
  tx_buf[1] = data;
  NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
  NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

  NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
  NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
  while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0);
}

void i2c_read(uint8_t addr)
{
  
  NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STARTRX_Msk | TWIM_SHORTS_LASTRX_STOP_Msk;

  tx_buf[0] = addr;
  //tx_buf[1] = addr;
  NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
  NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

  NRF_TWIM0-&amp;gt;RXD.MAXCNT = 1;
  NRF_TWIM0-&amp;gt;RXD.PTR = (uint32_t)&amp;amp;rx_buf[0];

  NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
  NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
  while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0);

 // return rx_buf[0];
}
#include &amp;lt;stdint.h&amp;gt;
int main(void)
{
uint16_t i ,i1,i2;
  volatile uint8_t data;
 NRF_GPIO-&amp;gt;PIN_CNF[PIN_SCL] = 
        (GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
      | (GPIO_PIN_CNF_DRIVE_S0D1     &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
      | (GPIO_PIN_CNF_PULL_Pullup    &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
      | (GPIO_PIN_CNF_INPUT_Connect  &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
      | (GPIO_PIN_CNF_DIR_Input      &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    
 NRF_GPIO-&amp;gt;PIN_CNF[PIN_SDA] = 
        (GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
      | (GPIO_PIN_CNF_DRIVE_S0D1     &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
      | (GPIO_PIN_CNF_PULL_Pullup    &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
      | (GPIO_PIN_CNF_INPUT_Connect  &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
      | (GPIO_PIN_CNF_DIR_Input      &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    
      
  NRF_TWIM0-&amp;gt;PSEL.SCL = PIN_SCL;
  NRF_TWIM0-&amp;gt;PSEL.SDA = PIN_SDA;

  NRF_TWIM0-&amp;gt;ADDRESS = DEVICE_ADDRESS;
  
  NRF_TWIM0-&amp;gt;FREQUENCY = TWIM_FREQUENCY_FREQUENCY_K400 &amp;lt;&amp;lt; TWIM_FREQUENCY_FREQUENCY_Pos;
  NRF_TWIM0-&amp;gt;SHORTS = 0;
  NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos;
 i2c_write(0x0, 0xFF);


  i2c_read(0x23);
 
  while (1)
  {
    __WFE();
  }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226246?ContentTypeID=1</link><pubDate>Thu, 19 Dec 2019 02:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53400139-944f-4c42-91a0-7b0f5537b606</guid><dc:creator>PoojaK</dc:creator><description>&lt;p&gt;Hi Hung Bui,&lt;/p&gt;
&lt;p&gt;I am not sending ACK or NACK in my code. I am just waiting for the slave to send a ACK pulse. The data sheet of AT24C512 says that once address has been transmitted we need to wait for the ACK bit and then continue further communication .&lt;/p&gt;
&lt;p&gt;I will try the code&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI with EEPROM using registers directly</title><link>https://devzone.nordicsemi.com/thread/226169?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 13:53:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64c2a86e-64c8-47d6-a482-90e6b714c95d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi PoojaK,&lt;/p&gt;
&lt;p&gt;In your application you don&amp;#39;t have to send ACK or NACK. It&amp;#39;s handled by the TWI module itself.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to capture a logic analyzer trace of the communication ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I would suggest you to have a look at this bare metal example here:&amp;nbsp;&lt;a href="https://github.com/andenore/NordicSnippets/tree/master/examples/i2c_master"&gt;https://github.com/andenore/NordicSnippets/tree/master/examples/i2c_master&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>