<?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 i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21151/why-i-am-i-not-able-to-write-anything-on-24lc356-eeprom</link><description>I am using blenano with mbed compiler and a 24LC256 eeprom. 
 the output o screen I get is the no. of total chars, i.e, 65355. below is the code. 
 #include &amp;quot;mbed.h&amp;quot;
#include &amp;quot;ble/BLE.h&amp;quot;
#include &amp;quot;SoftI2C.h&amp;quot;

int test =1000;

 lcd.clear();
 lcd</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Apr 2017 08:53:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21151/why-i-am-i-not-able-to-write-anything-on-24lc356-eeprom" /><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82765?ContentTypeID=1</link><pubDate>Wed, 12 Apr 2017 08:53:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1792bda-0a10-42a0-8e7b-2de3c8b867f1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Sorry, my bad. The line in read32 should be&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;result = (pbuf[0] &amp;lt;&amp;lt; 24) | (pbuf[1] &amp;lt;&amp;lt; 16) | (pbuf[2] &amp;lt;&amp;lt; 8) | (pbuf[3]);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82764?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 16:33:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:830015b0-d26b-464c-a09d-32cf3a47a933</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;I am getting 0 as out put I tried the following code. I call eepron_test function&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void AT24C512_WriteBytes(uint16_t addr, uint8_t *pbuf, uint16_t length)
{
    Wire.beginTransmission(addrr);
    Wire.write( (uint8_t)addr&amp;gt;&amp;gt;8 );
    Wire.write( (uint8_t)addr );
    Wire.write(pbuf, length);
    Wire.endTransmission();
}
 
void AT24C512_ReadBytes(uint16_t addr, uint8_t *pbuf, uint16_t length)
{
    Wire.beginTransmission(addrr);
    Wire.write( (uint8_t)addr&amp;gt;&amp;gt;8 );
    Wire.write( (uint8_t)addr );    
    Wire.endTransmission();
       
    Wire.requestFrom(addr+1, length);
    while( Wire.available() &amp;gt; 0 )
    {
        *pbuf = Wire.read();
        pbuf++;
    }
}
void write32(uint16_t addr, uint32_t value)
{
    uint8_t pbuf[4] = {value &amp;gt;&amp;gt; 24, value &amp;gt;&amp;gt; 16, value &amp;gt;&amp;gt; 8, value};
    AT24C512_WriteBytes(addr, pbuf, sizeof(pbuf));
}

uint32_t read32(uint16_t addr)
{
    uint32_t result;
    uint8_t pbuf[4];
    AT24C512_ReadBytes(addr, pbuf, sizeof(pbuf));
    result = (pbuf[0] &amp;lt;&amp;lt; 24) &amp;amp; (pbuf[1] &amp;lt;&amp;lt; 16) &amp;amp; (pbuf[2] &amp;lt;&amp;lt; 8) &amp;amp; (pbuf[3]);
    lcd.clear();sa
                lcd.setPosition(0,1);
        lcd.printf(&amp;quot;%d&amp;quot;, result);
        
        return result;
    
}

void eeprom_test() {
    Wire.begin(P0_8, P0_10, TWI_FREQUENCY_100K);
   write32(addrr, test);
   read32(addrr);
   wait(6);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82763?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 11:24:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78addd61-a240-4fae-8584-78bf9722f578</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Did you solve your initial problem? I have not tested this, but you should be able to write and read 32-bit words similar to this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void write32(uint16_t addr, uint32_t value)
{
	uint8_t pbuf[4] = {value &amp;gt;&amp;gt; 24, value &amp;gt;&amp;gt; 16, value &amp;gt;&amp;gt; 8, value};
	AT24C512_WriteBytes(addr, pbuf, sizeof(pbuf));
}

uint32_t read32(uint16_t addr)
{
	uint32_t result;
	uint8_t pbuf[4];
	AT24C512_ReadBytes(addr, pbuf, sizeof(pbuf));
	result = (pbuf[0] &amp;lt;&amp;lt; 24) | (pbuf[1] &amp;lt;&amp;lt; 16) | (pbuf[2] &amp;lt;&amp;lt; 8) | (pbuf[3]);
	return result;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82770?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2017 20:05:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09a36250-3d5b-41bf-9b99-8b6fce1caa0e</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;This code is told by rdbear labs to use for I2c. Can you please tell me how can I modify it to write and read an uint32_t value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82769?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2017 20:04:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2c29f06-3c63-44e9-a39c-e74cca0b4417</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;*/&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;mbed.h&amp;quot;
#include &amp;quot;wire.h&amp;quot;
 
#define BLE_Nano
//#define nRF_51822
 
 
#ifdef nRF_51822
#define SCL         28
#define SDA         29
#endif
 
#ifdef BLE_Nano
#define SCL         7  
#define SDA         6
#endif
 
#define DEV_ADDR    0xA0
 
Serial pc(USBTX, USBRX);
TwoWire Wire = TwoWire(NRF_TWI0);
 
void AT24C512_WriteBytes(uint16_t addr, uint8_t *pbuf, uint16_t length)
{
    Wire.beginTransmission(DEV_ADDR);
    Wire.write( (uint8_t)addr&amp;gt;&amp;gt;8 );
    Wire.write( (uint8_t)addr );
    Wire.write(pbuf, length);
    Wire.endTransmission();
}
 
void AT24C512_ReadBytes(uint16_t addr, uint8_t *pbuf, uint16_t length)
{
    Wire.beginTransmission(DEV_ADDR);
    Wire.write( (uint8_t)addr&amp;gt;&amp;gt;8 );
    Wire.write( (uint8_t)addr );    
    Wire.endTransmission();
       
    Wire.requestFrom(DEV_ADDR+1, length);
    while( Wire.available() &amp;gt; 0 )
    {
        *pbuf = Wire.read();
        pbuf++;
    }
}
 
 
static uint8_t wt_data[10] = {&amp;#39;H&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;W&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;d&amp;#39;};
static uint8_t rd_data[10];
 
static uint16_t index;
 
int main(void)
{
    pc.baud(9600);
    wait(5);
    //Wire.begin();
    Wire.begin(SCL, SDA, TWI_FREQUENCY_100K);
    pc.printf(&amp;quot;IIC Demo Start \r\n&amp;quot;);
    
    AT24C512_WriteBytes(0, wt_data, 10);
    wait(0.1);
    
    while(1)
    {
        AT24C512_ReadBytes(0, rd_data, 10);     
        pc.printf(&amp;quot;Read data from AT24C512 \r\n&amp;quot;);
        for(index=0; index&amp;lt;10; index++)
        {
            pc.putc(rd_data[index]);
            rd_data[index] = 0x00;
        }
        pc.printf(&amp;quot;\r\n&amp;quot;);
        wait(1);
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82768?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2017 20:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3699e91d-51e2-48fc-b881-93569ae34993</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;response is the char I am trying to use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82767?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2017 20:00:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79a31bc1-1b39-4055-a307-4616f3fc467c</guid><dc:creator>jay</dc:creator><description>&lt;p&gt;the value i want to save is 1000 as mentioned in the code. I dont know what is wrong in my code. If I use wire.h the value I get is a nine digit number.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: why i am i not able to write anything on 24LC356 eeprom</title><link>https://devzone.nordicsemi.com/thread/82766?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2017 08:42:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dd27bf6-257f-4276-8dcd-a3577d51e71c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Do you mean that you get &lt;em&gt;&amp;quot;address 65355&amp;quot;&lt;/em&gt; on the LCD? What is the values of &lt;code&gt;response[0]&lt;/code&gt; and &lt;code&gt;response[1]&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>