<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic sequence for writing to and reading from I2C EEPROM in CodeWarrior Development Tools</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/sequence-for-writing-to-and-reading-from-I2C-EEPROM/m-p/309056#M788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My chip is MK60DN512VLL10 and I am using I2C1 for writing to and reading from an external EEPROM that we have on our board. I checked with the datasheet of the EEPROM and it gives the following sequence. My I2C is isr based such that when sent and received are true I come out of the following while loops. The datasheet for the EEPROM is located at: &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.xilinx.com%2Fproducts%2Fboards%2Fml505%2Fdatasheets%2F6485.pdf" rel="nofollow" target="_blank"&gt;http://www.xilinx.com/products/boards/ml505/datasheets/6485.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My I2C device 7-bit address is 0x57.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main () {&lt;/P&gt;&lt;P&gt;UINT8 Data[10];&lt;/P&gt;&lt;P&gt;UINT8 passin;&lt;/P&gt;&lt;P&gt;UINT16 addr16;&lt;/P&gt;&lt;P&gt;UINT8 putin[5];&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1-WRITING (look at page 9 of the EEPROM link I provide):&lt;/P&gt;&lt;P&gt;passin = 0x57;&lt;/P&gt;&lt;P&gt;I&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;addr16 = 0x0000; //select address 0x0000 in EEPROM&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 2, LDD_I2C_NO_SEND_STOP);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;while (Sent == 0){}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;passin = 0xAA; //write value 0xAA to that address&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 1, LDD_I2C_NO_SEND_STOP);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;while (Sent == 0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2-READING (look at page 11 of the datasheet I provided):&lt;/P&gt;&lt;P&gt;passin = 0x57;&lt;/P&gt;&lt;P&gt;I2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;addr16 = 0x0000; //select address 0x0000 in EEEPROM&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 2, LDD_I2C_NO_SEND_STOP);&lt;/P&gt;&lt;P&gt;while (Sent == 0){}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; passin = 0x57;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Received = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C1_MasterReceiveBlock(I2C1ptr, putin, 5, LDD_I2C_SEND_STOP);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (Received == 0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; printf("E2PRM reading: 0x%x 0x%x 0x%x 0x%x 0x%x\n", putin[0], putin[1],putin[2],putin[3],putin[4]); //READING VALUES&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I do not get the 0xAA back. Why? Is there any other way to do this? Or am I making any mistakes here?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reading all 0xff back!&lt;/P&gt;&lt;P&gt;"E2PRM reading: 0xff 0xff 0xff 0xff 0xff"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 May 2014 18:13:09 GMT</pubDate>
    <dc:creator>mehdikarimibiuk</dc:creator>
    <dc:date>2014-05-02T18:13:09Z</dc:date>
    <item>
      <title>sequence for writing to and reading from I2C EEPROM</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/sequence-for-writing-to-and-reading-from-I2C-EEPROM/m-p/309056#M788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My chip is MK60DN512VLL10 and I am using I2C1 for writing to and reading from an external EEPROM that we have on our board. I checked with the datasheet of the EEPROM and it gives the following sequence. My I2C is isr based such that when sent and received are true I come out of the following while loops. The datasheet for the EEPROM is located at: &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.xilinx.com%2Fproducts%2Fboards%2Fml505%2Fdatasheets%2F6485.pdf" rel="nofollow" target="_blank"&gt;http://www.xilinx.com/products/boards/ml505/datasheets/6485.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;My I2C device 7-bit address is 0x57.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main () {&lt;/P&gt;&lt;P&gt;UINT8 Data[10];&lt;/P&gt;&lt;P&gt;UINT8 passin;&lt;/P&gt;&lt;P&gt;UINT16 addr16;&lt;/P&gt;&lt;P&gt;UINT8 putin[5];&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1-WRITING (look at page 9 of the EEPROM link I provide):&lt;/P&gt;&lt;P&gt;passin = 0x57;&lt;/P&gt;&lt;P&gt;I&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;addr16 = 0x0000; //select address 0x0000 in EEPROM&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 2, LDD_I2C_NO_SEND_STOP);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;while (Sent == 0){}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;passin = 0xAA; //write value 0xAA to that address&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 1, LDD_I2C_NO_SEND_STOP);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;while (Sent == 0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2-READING (look at page 11 of the datasheet I provided):&lt;/P&gt;&lt;P&gt;passin = 0x57;&lt;/P&gt;&lt;P&gt;I2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;addr16 = 0x0000; //select address 0x0000 in EEEPROM&lt;/P&gt;&lt;P&gt;Sent = 0;&lt;/P&gt;&lt;P&gt;I2C1_MasterSendBlock(I2C1ptr, &amp;amp;passin , 2, LDD_I2C_NO_SEND_STOP);&lt;/P&gt;&lt;P&gt;while (Sent == 0){}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; passin = 0x57;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C1_SelectSlaveDevice(I2C1ptr, LDD_I2C_ADDRTYPE_7BITS, passin);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Received = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C1_MasterReceiveBlock(I2C1ptr, putin, 5, LDD_I2C_SEND_STOP);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (Received == 0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; printf("E2PRM reading: 0x%x 0x%x 0x%x 0x%x 0x%x\n", putin[0], putin[1],putin[2],putin[3],putin[4]); //READING VALUES&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I do not get the 0xAA back. Why? Is there any other way to do this? Or am I making any mistakes here?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reading all 0xff back!&lt;/P&gt;&lt;P&gt;"E2PRM reading: 0xff 0xff 0xff 0xff 0xff"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 18:13:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/sequence-for-writing-to-and-reading-from-I2C-EEPROM/m-p/309056#M788</guid>
      <dc:creator>mehdikarimibiuk</dc:creator>
      <dc:date>2014-05-02T18:13:09Z</dc:date>
    </item>
  </channel>
</rss>

