<?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 eeprom read i2c kinetis in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/eeprom-read-i2c-kinetis/m-p/921039#M53768</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how&amp;nbsp; to read eeprom mac id from my custom board.&amp;nbsp; controller is mk10dx256. eeprom is microchip&amp;nbsp;/24AA025E64.adress i have to access is 0xfa. i have to read last 6 bits to get the unique mac id of the eeprom.&lt;/P&gt;&lt;P&gt;data sheet of eeprom&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf" title="http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf"&gt;http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;program:&lt;/P&gt;&lt;P&gt;#include &amp;lt;__cross_studio_io.h&amp;gt;&lt;BR /&gt;#include "MK10DZ10.h"&lt;BR /&gt;#define MWSR 0x00 /* Master write */ &lt;BR /&gt;#define MRSW 0x01 /* Master read */ &lt;BR /&gt;#define reg EEPROM &lt;BR /&gt;void i2c_Wait(void);&lt;BR /&gt;i2c_Wait()&lt;BR /&gt;{ &lt;BR /&gt; while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) { &lt;BR /&gt; } &lt;BR /&gt; // Clear the interrupt flag &lt;BR /&gt; I2C1_S |= I2C_S_IICIF_MASK; &lt;BR /&gt;} &lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;unsigned char u8Address; &lt;BR /&gt;unsigned char u8Register;&lt;BR /&gt; unsigned char u8Data = 'a';&lt;BR /&gt;SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;&lt;BR /&gt;PORTC_PCR10 |= PORT_PCR_MUX(2);&lt;BR /&gt;PORTC_PCR11 |= PORT_PCR_MUX(2);&lt;BR /&gt;//i2c1&lt;BR /&gt;SIM_SCGC4 |= (SIM_SCGC4_I2C1_MASK);&lt;BR /&gt; // START I2C&lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TX_MASK );&lt;/P&gt;&lt;P&gt;I2C1_C1 |= ( I2C_C1_MST_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_IICEN_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TXAK_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_IICIE_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_RSTA_MASK ) ;&lt;/P&gt;&lt;P&gt;I2C1_D = u8Data;&lt;BR /&gt; I2C1_F = 0;&lt;BR /&gt; I2C1_F = 0x80;&lt;BR /&gt; &lt;BR /&gt; I2C1_F |= I2C_F_ICR( 0x18 ) ;&lt;/P&gt;&lt;P&gt;//i2c_Wait()&lt;BR /&gt;//{ &lt;BR /&gt;// while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) { &lt;BR /&gt;// } &lt;BR /&gt;// // Clear the interrupt flag &lt;BR /&gt;// I2C1_S |= I2C_S_IICIF_MASK; &lt;BR /&gt;//} &lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //STOP I2C&lt;BR /&gt; //I2C1_C1 &amp;amp;= ~( I2C_C1_TX_MASK );&lt;BR /&gt;unsigned char I2C_ReadRegister_uc (unsigned char u8Address, unsigned char u8Register ){ &lt;BR /&gt; unsigned char u8Data; &lt;BR /&gt; unsigned char u8AddressW, u8AddressR; &lt;BR /&gt; /* shift ID in right position */ &lt;BR /&gt; u8AddressW = (u8Address &amp;lt;&amp;lt; 1) | MWSR; // Write Address &lt;BR /&gt; u8AddressR = (u8Address &amp;lt;&amp;lt; 1) | MRSW; // Read Address &lt;BR /&gt; /* send start signal */ &lt;BR /&gt; //i2c_Start(); &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TX_MASK );&lt;/P&gt;&lt;P&gt;I2C1_C1 |= ( I2C_C1_MST_MASK ) ; &lt;BR /&gt; /* send ID with Write bit */ &lt;BR /&gt; //i2c_write_byte(u8AddressW);&lt;BR /&gt; I2C1_D = u8AddressW; &lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // send Register address &lt;BR /&gt; //i2c_write_byte(u8Register); &lt;BR /&gt; I2C1_D = u8Register;&lt;BR /&gt; printf("register");&lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // send repeated start to switch to read mode &lt;BR /&gt; //i2c_RepeatedStart(); &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_RSTA_MASK ) ; &lt;BR /&gt; // re send device address with read bit &lt;BR /&gt; //i2c_write_byte(u8AddressR);&lt;BR /&gt; I2C1_D = u8AddressR; &lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // set K40 in read mode &lt;BR /&gt; // i2c_EnterRxMode(); &lt;BR /&gt; I2C1_C1 &amp;amp;= ~I2C_C1_TX_MASK; &lt;BR /&gt; I2C1_C1 |= I2C_C1_TXAK_MASK; &lt;BR /&gt; u8Data = I2C1_D;&lt;BR /&gt; //i2c_read_byte(); &lt;BR /&gt; // send stop signal so we only read 8 bits &lt;BR /&gt; //i2c_Stop &lt;BR /&gt; I2C1_C1 &amp;amp;= ~( I2C_C1_TX_MASK );&lt;BR /&gt; debug_printf("%c",u8Data); &lt;BR /&gt; return 1; &lt;BR /&gt;}&lt;BR /&gt;while(1)&lt;BR /&gt;{I2C_ReadRegister_uc(0xFA,' $$');}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;$$ i cant fnd the&amp;nbsp; register name to access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while i tried to run it was printing FA directly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Sep 2019 06:11:20 GMT</pubDate>
    <dc:creator>gnsh2196</dc:creator>
    <dc:date>2019-09-27T06:11:20Z</dc:date>
    <item>
      <title>eeprom read i2c kinetis</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/eeprom-read-i2c-kinetis/m-p/921039#M53768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how&amp;nbsp; to read eeprom mac id from my custom board.&amp;nbsp; controller is mk10dx256. eeprom is microchip&amp;nbsp;/24AA025E64.adress i have to access is 0xfa. i have to read last 6 bits to get the unique mac id of the eeprom.&lt;/P&gt;&lt;P&gt;data sheet of eeprom&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf" title="http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf"&gt;http://ww1.microchip.com/downloads/en/devicedoc/20002124g.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;program:&lt;/P&gt;&lt;P&gt;#include &amp;lt;__cross_studio_io.h&amp;gt;&lt;BR /&gt;#include "MK10DZ10.h"&lt;BR /&gt;#define MWSR 0x00 /* Master write */ &lt;BR /&gt;#define MRSW 0x01 /* Master read */ &lt;BR /&gt;#define reg EEPROM &lt;BR /&gt;void i2c_Wait(void);&lt;BR /&gt;i2c_Wait()&lt;BR /&gt;{ &lt;BR /&gt; while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) { &lt;BR /&gt; } &lt;BR /&gt; // Clear the interrupt flag &lt;BR /&gt; I2C1_S |= I2C_S_IICIF_MASK; &lt;BR /&gt;} &lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;unsigned char u8Address; &lt;BR /&gt;unsigned char u8Register;&lt;BR /&gt; unsigned char u8Data = 'a';&lt;BR /&gt;SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;&lt;BR /&gt;PORTC_PCR10 |= PORT_PCR_MUX(2);&lt;BR /&gt;PORTC_PCR11 |= PORT_PCR_MUX(2);&lt;BR /&gt;//i2c1&lt;BR /&gt;SIM_SCGC4 |= (SIM_SCGC4_I2C1_MASK);&lt;BR /&gt; // START I2C&lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TX_MASK );&lt;/P&gt;&lt;P&gt;I2C1_C1 |= ( I2C_C1_MST_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_IICEN_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TXAK_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_IICIE_MASK ) ; &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_RSTA_MASK ) ;&lt;/P&gt;&lt;P&gt;I2C1_D = u8Data;&lt;BR /&gt; I2C1_F = 0;&lt;BR /&gt; I2C1_F = 0x80;&lt;BR /&gt; &lt;BR /&gt; I2C1_F |= I2C_F_ICR( 0x18 ) ;&lt;/P&gt;&lt;P&gt;//i2c_Wait()&lt;BR /&gt;//{ &lt;BR /&gt;// while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) { &lt;BR /&gt;// } &lt;BR /&gt;// // Clear the interrupt flag &lt;BR /&gt;// I2C1_S |= I2C_S_IICIF_MASK; &lt;BR /&gt;//} &lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //STOP I2C&lt;BR /&gt; //I2C1_C1 &amp;amp;= ~( I2C_C1_TX_MASK );&lt;BR /&gt;unsigned char I2C_ReadRegister_uc (unsigned char u8Address, unsigned char u8Register ){ &lt;BR /&gt; unsigned char u8Data; &lt;BR /&gt; unsigned char u8AddressW, u8AddressR; &lt;BR /&gt; /* shift ID in right position */ &lt;BR /&gt; u8AddressW = (u8Address &amp;lt;&amp;lt; 1) | MWSR; // Write Address &lt;BR /&gt; u8AddressR = (u8Address &amp;lt;&amp;lt; 1) | MRSW; // Read Address &lt;BR /&gt; /* send start signal */ &lt;BR /&gt; //i2c_Start(); &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_TX_MASK );&lt;/P&gt;&lt;P&gt;I2C1_C1 |= ( I2C_C1_MST_MASK ) ; &lt;BR /&gt; /* send ID with Write bit */ &lt;BR /&gt; //i2c_write_byte(u8AddressW);&lt;BR /&gt; I2C1_D = u8AddressW; &lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // send Register address &lt;BR /&gt; //i2c_write_byte(u8Register); &lt;BR /&gt; I2C1_D = u8Register;&lt;BR /&gt; printf("register");&lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // send repeated start to switch to read mode &lt;BR /&gt; //i2c_RepeatedStart(); &lt;BR /&gt; I2C1_C1 |= ( I2C_C1_RSTA_MASK ) ; &lt;BR /&gt; // re send device address with read bit &lt;BR /&gt; //i2c_write_byte(u8AddressR);&lt;BR /&gt; I2C1_D = u8AddressR; &lt;BR /&gt; i2c_Wait(); &lt;BR /&gt; // set K40 in read mode &lt;BR /&gt; // i2c_EnterRxMode(); &lt;BR /&gt; I2C1_C1 &amp;amp;= ~I2C_C1_TX_MASK; &lt;BR /&gt; I2C1_C1 |= I2C_C1_TXAK_MASK; &lt;BR /&gt; u8Data = I2C1_D;&lt;BR /&gt; //i2c_read_byte(); &lt;BR /&gt; // send stop signal so we only read 8 bits &lt;BR /&gt; //i2c_Stop &lt;BR /&gt; I2C1_C1 &amp;amp;= ~( I2C_C1_TX_MASK );&lt;BR /&gt; debug_printf("%c",u8Data); &lt;BR /&gt; return 1; &lt;BR /&gt;}&lt;BR /&gt;while(1)&lt;BR /&gt;{I2C_ReadRegister_uc(0xFA,' $$');}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;$$ i cant fnd the&amp;nbsp; register name to access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while i tried to run it was printing FA directly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Sep 2019 06:11:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/eeprom-read-i2c-kinetis/m-p/921039#M53768</guid>
      <dc:creator>gnsh2196</dc:creator>
      <dc:date>2019-09-27T06:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: eeprom read i2c kinetis</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/eeprom-read-i2c-kinetis/m-p/921040#M53769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The pins need to be set to open-drain mode, as well as to their I2C peripheral mode.&lt;BR /&gt;I2C: &lt;A href="http://www.utasker.com/docs/uTasker/uTasker_I2C.pdf" target="test_blank"&gt;http://www.utasker.com/docs/uTasker/uTasker_I2C.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget that I2C dead-lock recovery should be considered for real product development:&lt;BR /&gt;&lt;A href="https://community.nxp.com/thread/322977" target="test_blank"&gt;https://community.nxp.com/thread/322977&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proven I2C solution with EEPROM support (and simulation for Kinetis, I2C controller and EEPROM is available in the open source uTasker project (link below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Complete Kinetis solutions for professional needs, training and support: &lt;A href="http://www.utasker.com/kinetis.html" target="test_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;uTasker: supporting &amp;gt;1'000 registered Kinetis users get products faster and cheaper to market&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Request Free emergency remote desk-top consulting at &lt;A href="http://www.utasker.com/services.html" target="test_blank"&gt;http://www.utasker.com/services.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Open Source version at &lt;A href="https://github.com/uTasker/uTasker-Kinetis" target="test_blank"&gt;https://github.com/uTasker/uTasker-Kinetis&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="https://community.nxp.com/thread/512558" target="test_blank"&gt;https://community.nxp.com/thread/512558&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Sep 2019 10:57:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/eeprom-read-i2c-kinetis/m-p/921040#M53769</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-09-27T10:57:51Z</dc:date>
    </item>
  </channel>
</rss>

