<?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>8-bit MicrocontrollersのトピックRe: AW32: I2C Problem</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145071#M7060</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yes, you are correct the data sheets are watered down a bit, sorry about that.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Looks like you are using polled&amp;nbsp;code&amp;nbsp;and eventhough I do not like it, when I benchmarked the I2C S08 and S12s, I found the following:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I can share with you is that I needed to be careful about my timing and delays were needed from the time I write to the data register and checking the flags for a byte completion flag set contition. It is also important to have the pullups between 2-4k Ohms or you will get hung up. The TC flag was not logically doing what I wanted to so I relied solely on IBIF flag.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also the Baud Register must have the correct value and account for the correct transfer rate and setup/hold times. Please note that for one baud rate settings there may be 2 or 3 different values you can assign and only one will work for your setup/hold times correctly over temp.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards and I hope this helps you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Edgar Saenz.&lt;/DIV&gt;&lt;DIV&gt;Product Engineering,&lt;/DIV&gt;&lt;DIV&gt;Austin Texas.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Nov 2008 01:05:55 GMT</pubDate>
    <dc:creator>Fonsi</dc:creator>
    <dc:date>2008-11-26T01:05:55Z</dc:date>
    <item>
      <title>AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145050#M7039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;First of all, Freescale, I hate your datasheets !&lt;/DIV&gt;&lt;DIV&gt;But I like the forum, anyway...&amp;nbsp;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm living interesting problem with I2C and EEPROM AT24C512BN.&lt;/DIV&gt;&lt;DIV&gt;If I debug test routine below, it works, "count" be equal to "okunan".&lt;/DIV&gt;&lt;DIV&gt;If I directly run the code, it fails at EE_ReadBuffer function. The function returns 0.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;Test routine:&amp;nbsp; count = 0x89654321;&amp;nbsp; // unsigned long&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp; Init_i2c();&amp;nbsp; if(EE_WriteBuffer(0, &amp;amp;count, 4, I2C_ADR_EEPROM0))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DispMsg(MSG_FILL, 0);&amp;nbsp; else DispMsg(MSG_ERROR_CODE, 1);&amp;nbsp; if(EE_ReadBuffer(0, &amp;amp;okunan, 4, I2C_ADR_EEPROM0))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DispMsg(MSG_FILL, 0);&amp;nbsp; else DispMsg(MSG_ERROR_CODE, 2);&amp;nbsp;&amp;nbsp;&amp;nbsp; if(count == okunan)&amp;nbsp;&amp;nbsp;&amp;nbsp; DispMsg(MSG_FILL, 0);&amp;nbsp; else DispMsg(MSG_ERROR_CODE, 3);&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I change the i2c_start()&amp;nbsp;function such as below: It start working in debug or not.&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void i2c_start(void){&amp;nbsp; IIC1S_SRW = 0; // R/W bit = 0;&amp;nbsp; IIC1C_IICEN = 0;&amp;nbsp; IIC1C = 0b10011000;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1C_MST = 1; // generate START condition}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I don't understand the problem due to the datasheet doesn't explain I2C module well.&lt;BR /&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void Init_i2c(void){&amp;nbsp; // Bus = 18.432MHz;&amp;nbsp; // mul=4, ICR=0x0D =&amp;gt; SCL Div=48, i2c_ Bus Freq = 96Khz, SDA Hold Time = 600ns&amp;nbsp; IIC1F = 0b10001101;&amp;nbsp; IIC1S_SRW = 0; // R/W bit = 0;&amp;nbsp; // Enable i2c module&amp;nbsp; // not generate ACK by master after transfer;&amp;nbsp; // TX mode&amp;nbsp; // Slave mode actually;&amp;nbsp; IIC1C = 0b10011000;&amp;nbsp; }void i2c_start(void){&amp;nbsp; IIC1C_MST = 1; // generate START condition}void i2c_stop(void){&amp;nbsp; IIC1C_MST = 0; // generate STOP condition;&amp;nbsp; }void i2c_restart(void){&amp;nbsp; IIC1C_RSTA = 1; // generate RESTART condition}void i2c_sendbyte(unsigned char data){&amp;nbsp; IIC1C_TX = 1; // transmit&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1D = data;&amp;nbsp; while(!IIC1S_IICIF); // wait until Transfer to complete;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1S_IICIF = 1;}char i2c_getack(void){&amp;nbsp; return(!IIC1S_RXAK); // ACK gelmiş ise 1 döner, gelmemişse 0}unsigned char i2c_getbyte(char send_ack){&amp;nbsp; unsigned char data;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1C_TX = 0; // set up to receive;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1C_TXAK = send_ack—0:1;&amp;nbsp;&amp;nbsp;&amp;nbsp; data = IIC1D; // dummy read;&amp;nbsp; while(!IIC1S_IICIF); // wait until Transfer to complete;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC1S_IICIF = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; data = IIC1D; // read right data;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(data);}/////////////////////////////////////////////////////////////////////////////////// EEPROM RUTINLERI Atmel AT24C512BN-SH-B veya ST M24512-RM/////////////////////////////////////////////////////////////////////////////////unsigned char EE_WaitForACK(unsigned char external_adr){&amp;nbsp; unsigned char counter = 100;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char ack;&amp;nbsp; unsigned char ControlByte = 0b10100000; // Yazma modu, A2, A1, A0 = 0&amp;nbsp;&amp;nbsp;&amp;nbsp; ControlByte |= ((external_adr &amp;lt;&amp;lt; 1) &amp;amp; 0b00001110);&amp;nbsp;&amp;nbsp;&amp;nbsp; do&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_start();&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_sendbyte(ControlByte);&amp;nbsp;&amp;nbsp;&amp;nbsp; ack = i2c_getack(); // i2cgetack, ack alınmış ise 1 döner!&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --counter; // her deneme 175uS sürüyor, 29 deneme &amp;gt; 5ms yapar.&amp;nbsp; } while(!ack &amp;amp;&amp;amp; (counter != 0));&amp;nbsp;&amp;nbsp;&amp;nbsp; return(ack);}unsigned char EE_ReadBuffer(unsigned int Adr, unsigned char* Data, unsigned int size, unsigned char external_adr){&amp;nbsp; // Control Byte = 1 0 1 0 A2 A1 A0 R/W. unsigned char ControlByte = 0b10100000; // Yazma modu, A2, A1, A0 = 0 unsigned char AddrHigh = (Adr &amp;gt;&amp;gt; 8) &amp;amp; 0xFF; unsigned char AddrLow = (Adr &amp;amp; 0xFF);&amp;nbsp; ControlByte |= ((external_adr &amp;lt;&amp;lt; 1) &amp;amp; 0b00001110);&amp;nbsp; i2c_start();&amp;nbsp; // Control Byte = 1 0 1 0 A2 A1 A0 R/W&amp;nbsp; i2c_sendbyte(ControlByte); if(!i2c_getack()) {&amp;nbsp; i2c_stop();&amp;nbsp; return(0); } // Address High Byte i2c_sendbyte(AddrHigh); if(!i2c_getack()) {&amp;nbsp; i2c_stop();&amp;nbsp; return(0); } // Address Low Byte i2c_sendbyte(AddrLow); if(!i2c_getack()) {&amp;nbsp; i2c_stop();&amp;nbsp; return(0); } // Read i2c_restart();&amp;nbsp; // Control Byte to read ControlByte |= 0b00000001; // Okuma modu i2c_sendbyte(ControlByte); if(!i2c_getack())&amp;nbsp; {&amp;nbsp; i2c_stop();&amp;nbsp; return(0); } do {&amp;nbsp; *Data++ = i2c_getbyte(size != 1);&amp;nbsp;&amp;nbsp; } while(--size);&amp;nbsp; i2c_stop();&amp;nbsp; return(1);}char EE_WriteBuffer(unsigned int Adr, unsigned char* Data, unsigned int size, unsigned char external_adr){ unsigned int _PAGE = 0xFFFF; // önceki page&amp;nbsp; do&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int CURRENT_PAGE = Adr &amp;amp; 0b1111111110000000; // page size 128 byte&amp;nbsp;&amp;nbsp;&amp;nbsp; if(CURRENT_PAGE != _PAGE)&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Control Byte = 1 0 1 0 A2 A1 A0 R/W.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char ControlByte = 0b10100000; // Yazma modu, A2, A1, A0 = 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char AddrHigh = (Adr &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char AddrLow = (Adr &amp;amp; 0xFF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ControlByte |= ((external_adr &amp;lt;&amp;lt; 1) &amp;amp; 0b00001110);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(_PAGE != 0xFFFF)&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!EE_WaitForACK(external_adr))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(0);&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_start();&amp;nbsp;&amp;nbsp;&amp;nbsp; // Control Byte = 1 0 1 0 A2 A1 A0 R/W.&amp;nbsp;&amp;nbsp; i2c_sendbyte(ControlByte);&amp;nbsp;&amp;nbsp; if(!i2c_getack())&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(0);&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; // Address High Byte&amp;nbsp;&amp;nbsp; i2c_sendbyte(AddrHigh);&amp;nbsp;&amp;nbsp; if(!i2c_getack())&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(0);&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; // Address Low Byte&amp;nbsp;&amp;nbsp; i2c_sendbyte(AddrLow);&amp;nbsp;&amp;nbsp; if(!i2c_getack())&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(0);&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _PAGE = CURRENT_PAGE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } //if(CURRENT_PAGE != _PAGE)&amp;nbsp;&amp;nbsp;&amp;nbsp; i2c_sendbyte(*Data++);&amp;nbsp; if(!i2c_getack())&amp;nbsp; {&amp;nbsp;&amp;nbsp; i2c_stop();&amp;nbsp;&amp;nbsp; return(0);&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; Adr++; } while(--size); i2c_stop();&amp;nbsp; return(EE_WaitForACK(external_adr));}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by BasePointer on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-09-12&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;04:50 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:46:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145050#M7039</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2020-10-29T08:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145051#M7040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Take a look at AN3291.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It explains everything you need to know to use the I2C on the HC(S)08 and HC(S)12 devices.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/app_note/AN3291.pdf?srch=1" rel="nofollow" target="_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/app_note/AN3291.pdf?srch=1&lt;/A&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2007 08:04:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145051#M7040</guid>
      <dc:creator>Witztronics</dc:creator>
      <dc:date>2007-09-13T08:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145052#M7041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Beware of the I2C module.&amp;nbsp; I worked on a project two years ago using the GB60 and a Dallas DS2482-800 as the only two devices on the bus.&amp;nbsp; While working with the Dallas engineers we came upon an issue where the Dallas state machine and the GB60 were incompatible.&amp;nbsp; The GB60 would hang the SDA line low until a power cycle and there was no way to tell from the firmware what the problem was other than communications had stopped.&amp;nbsp; The I2C module was made for interrupt use only and if an event did not generate an interrup there was no way to poll the state of the I2C module for recovery information.&lt;BR /&gt;&lt;BR /&gt;At the time, I could not get a freescale support engineer on the phone and could only communicate by email about once every day or so which was taking too long.&amp;nbsp; The GB60 is one of the first Freescale CPUs to have I2C and the I2C module was ported over from the S12.&amp;nbsp; The only sample cade was for the S12 which had slightly different naming conventions and slightly different signaling which made the code essentially useless.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was programming using Bytecraft C and ended up writing an I2C assembler bit bang library to handle the DS2482.&amp;nbsp;&amp;nbsp; This works flawlessly.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;I am sure this has been fixed since I reported it in detail with code samples and logic analyzer captures to the Freescale engineer I was in emailing at the time.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt;&lt;BR /&gt;Peter House&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2007 20:25:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145052#M7041</guid>
      <dc:creator>PeterHouse</dc:creator>
      <dc:date>2007-09-13T20:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145053#M7042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Peter,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I think I2C Module of AW32 still has some problems. It is not working stabile, it work for first usage but&amp;nbsp;doesn't for second&amp;nbsp;and later... Exactly you mentioned, sometimes SDA line is hanged at low. I don't know why. In spite of setting whole I2C control byte(IICC) at a time, it sometimes doesn't generate start, stop or set IICIF flag.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I implemented my own software I2C routines without using I2C Module. I have 4 device on the bus, two EEPROMs, one RTC and&amp;nbsp;one temperature measurement IC. All works flawlessly now.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PS: Suggested application note also&amp;nbsp;didn't worked for me. I wonder why writter of this application note try to set SRW that&amp;nbsp;was indicated as&amp;nbsp;read only in the datasheet? I also would like to ask that what happens if slave on the bus can't send the ACK, while(RXAK)?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Sep 2007 02:02:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145053#M7042</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-09-15T02:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145054#M7043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi folks.&lt;/DIV&gt;&lt;DIV&gt;I just burned the last week discovering the same thing on an AW60. I attempted to replace a previously working bit-bang routine with an LCD driver and EEPROM on the same IIC bus.&amp;nbsp; However, trying to run the IIC in a polled mode in combination with an RTI interrupt timer results in some very strange problems in the IIC module.&amp;nbsp; Perhaps its me, but the docs on working with this module are really poor.&amp;nbsp; I can get the RTI timer to run fine, and seperately, I can get the IIC to work fine most of the time, but I can never get them to run together with the IIC polled.&amp;nbsp; As much as I would love to hammer out the code details on this, I'm already behind because of this problem.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2007 11:51:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145054#M7043</guid>
      <dc:creator>JMAC</dc:creator>
      <dc:date>2007-09-18T11:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145055#M7044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;JMAC,&lt;BR /&gt;&lt;BR /&gt;As I recall the IIC module on the GB60 did not have enough flags to run in polled mode.&amp;nbsp; There are interrupts with no way to tell if they fired without interrupt code.&amp;nbsp; I would never recommend running a module of this complexity in polled mode when a working interrupt mode is available.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, as far as I can tell, there is no working, reliable interrupt mode in the GB60 IIC peripheral and polling is not an option.&lt;BR /&gt;&lt;BR /&gt;I do not know if the AW60 IIC module is the same as the GB60.&amp;nbsp; If you can run it polled then it must have more status flags available and is possibly a different module.&amp;nbsp; If your application is not CPU bound then I would consider a bit-bang approach.&lt;BR /&gt;&lt;BR /&gt;I did not write a general purpose IIC module as I had only a single IIC device to with which to communicate.&amp;nbsp; Otherwise, I would offer my IIC code.&lt;BR /&gt;&lt;BR /&gt;Peter House&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2007 20:04:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145055#M7044</guid>
      <dc:creator>PeterHouse</dc:creator>
      <dc:date>2007-09-18T20:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145056#M7045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Did freescale release any errata for this?&lt;/DIV&gt;&lt;DIV&gt;If not, they should provide us a sample code that works.&lt;/DIV&gt;&lt;DIV&gt;I've searched the forum and saw that a lot of developers lived similar problems with I2C module.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2007 19:36:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145056#M7045</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-09-22T19:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145057#M7046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not sure if you have resolved your I2C issue but it is somewhat difficult to&amp;nbsp;debug code via emails. I can speculate and make suggestion.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I always advice I2C customers to&amp;nbsp;run&amp;nbsp;the module in Interrupt driven mode&amp;nbsp;but if they must run in polled mode to&amp;nbsp;make sure&amp;nbsp;and place some delays between bytes and start and stop symbols. I have written I2C polled&amp;nbsp;routines in the past and what I noticed is that Start and Stop symbols delays are needed. There is also&amp;nbsp; hardware considerations one must take into account to make sure that you avoid getting LOAs and the Master is forced into slave mode.&amp;nbsp;&amp;nbsp;In and ideal world the code you present should work without a problem, but we never design in that environment.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you are still having problems, please submit a technical service request and we will help you resolve your issue.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Issues we need to consider:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1. Is your bit rate correctly and compliant with your peripheral device?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;2. Is your hardware set up correctly?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Edgar Saenz.&lt;/DIV&gt;&lt;DIV&gt;TIC 16 bit Team Leader.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2007 20:50:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145057#M7046</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2007-09-26T20:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145058#M7047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi Edgar,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I added some delay after start and stop. You can see my last implementation below. Unfortunately, it is&amp;nbsp; still not working for the second time.&amp;nbsp; That means EE_WriteBuffer function (1) in test routine&amp;nbsp; returns 1 but the EE_ReadBuffer function (2) never returns and crash at i2c_waitforflag. TCF never sets there.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My hardware (10Kohm pull-up on SCL and SDA) is working with my IIC software implementation.&lt;/DIV&gt;&lt;DIV&gt;Related EEPROMs support communication speed up to 400kHz, my hardware is so, too. (there is no caps on the bus) Oscilloscope output of the bus seems clean. I try communication at 100kHz.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;BP&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;  Test routine:  count = 0x89654321;  if(EE_WriteBuffer(0, &amp;amp;count, 4, I2C_ADR_EEPROM0))  ...........1      DispMsg(MSG_FILL, 0);  else DispMsg(MSG_ERROR_CODE, 1);  if(EE_ReadBuffer(0, &amp;amp;okunan, 4, I2C_ADR_EEPROM0))  ...........2        DispMsg(MSG_FILL, 0);  else DispMsg(MSG_ERROR_CODE, 2);    if(count == okunan)    DispMsg(MSG_FILL, 0);  else DispMsg(MSG_ERROR_CODE, 3);&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void Wait_sh(unsigned char time){   unsigned int i, temp_t = time;   for (i=0;i&amp;lt;temp_t;i++)      {      asm nop;      }}void Init_I2C(void){  // Bus = 18.432MHz;  // mul=4, ICR=0x0D =&amp;gt; SCL Div=48, i2c_ Bus Freq = 96Khz, SDA Hold Time = 600ns    IIC1C = 0;/*  PTCD_PTCD0 = 0;  PTCD_PTCD0 = 0;    PTCDD_PTCDD0 = 0;  PTCDD_PTCDD0 = 0;  PTADS = 0;  PTASE = 0;*/  Wait_sh(80);    IIC1A = 0;  IIC1F = 0b10001101;  IIC1C = 0b10000000;    Wait_sh(80);}void i2c_start(void){     Init_I2C();    IIC1S = 0b10010010; // clear interrupts     IIC1C = 0b10111000; // Start, TX, NOACK    Wait_sh(80);}void i2c_stop(void){  IIC1S = 0b10010010; // clear interrupts  IIC1C = 0b10000000;  Wait_sh(80);}void i2c_restart(void){  IIC1C = 0b10111100; // Start, TX, NOACK, RESTART  Wait_sh(80);}char i2c_waitforflag(void){  IIC1SSTR status;    Wait_sh(80);    do  {    status.Byte = IIC1S;  } while(!status.Bits.TCF);    IIC1S = 0b10010010; // clear interrupts    return(!status.Bits.RXAK);}char i2c_sendbyte(unsigned char data){  if(IIC1C != 0b10111000) IIC1C = 0b10111000;  IIC1D = data;    return(i2c_waitforflag());}unsigned char i2c_getbyte(char send_ack){  unsigned char data;    if(send_ack) IIC1C = 0b10100000; // RX, SEND_ACK   else IIC1C = 0b10101000; // RX, NO_ACK  IIC1D;  i2c_waitforflag();  data = IIC1D; // read right data;    Wait_sh(80);    return(data);}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;unsigned char EE_WaitForACK(unsigned char control_byte){  unsigned char counter = 200;    unsigned char ack;    unsigned char ControlByte = control_byte;    ControlByte &amp;amp;= 0b11111110;    do  {    i2c_start();    ack = i2c_sendbyte(ControlByte);        i2c_stop();      --counter; // her deneme 175uS sürüyor, 29 deneme &amp;gt; 5ms yapar.  } while(!ack &amp;amp;&amp;amp; (counter != 0));    return(ack);}char EE_ReadBuffer(unsigned int Adr, unsigned char* Data, unsigned int size, unsigned char external_adr){  // Control Byte = 1 0 1 0 A2 A1 A0 R/W. unsigned char ControlByte = 0b10100000; // Yazma modu, A2, A1, A0 = 0 unsigned char AddrHigh = (Adr &amp;gt;&amp;gt; 8) &amp;amp; 0xFF; unsigned char AddrLow = (Adr &amp;amp; 0xFF);  ControlByte |= ((external_adr &amp;lt;&amp;lt; 1) &amp;amp; 0b00001110);  i2c_start();  // Control Byte = 1 0 1 0 A2 A1 A0 R/W  if(!i2c_sendbyte(ControlByte)) {  i2c_stop();  return(0); } // Address High Byte  if(!i2c_sendbyte(AddrHigh)) {  i2c_stop();  return(0); } // Address Low Byte  if(!i2c_sendbyte(AddrLow)) {  i2c_stop();  return(0); } // Read i2c_restart();   // Control Byte to read ControlByte |= 0b00000001; // Okuma modu   if(!i2c_sendbyte(ControlByte))  {  i2c_stop();  return(0); } do {  *Data++ = i2c_getbyte(size != 1);   } while(--size);  i2c_stop();  return(1);}char EE_WriteBuffer(unsigned int Adr, unsigned char* Data, unsigned int size, unsigned char external_adr){ unsigned int _PAGE = 0xFFFF; // önceki page   // Control Byte = 1 0 1 0 A2 A1 A0 R/W.  unsigned char ControlByte = 0b10100000; // Yazma modu, A2, A1, A0 = 0   do  {     unsigned int CURRENT_PAGE = Adr &amp;amp; 0b1111111110000000; // page size 128 byte    if(CURRENT_PAGE != _PAGE)  {     unsigned char AddrHigh = (Adr &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;     unsigned char AddrLow = (Adr &amp;amp; 0xFF);          ControlByte |= ((external_adr &amp;lt;&amp;lt; 1) &amp;amp; 0b00001110);      if(_PAGE != 0xFFFF)   {    i2c_stop();        if(!EE_WaitForACK(external_adr))       return(0);   }      //i2c_start();   i2c_start();    // Control Byte = 1 0 1 0 A2 A1 A0 R/W.      if(!i2c_sendbyte(ControlByte))   {    i2c_stop();        return(0);   }   // Address High Byte      if(!i2c_sendbyte(AddrHigh))   {    i2c_stop();        return(0);   }   // Address Low Byte      if(!i2c_sendbyte(AddrLow))   {    i2c_stop();        return(0);   }      _PAGE = CURRENT_PAGE;     } //if(CURRENT_PAGE != _PAGE)    if(!i2c_sendbyte(*Data++))  {   i2c_stop();   return(0);  }    Adr++; } while(--size); i2c_stop();  return(EE_WaitForACK(ControlByte));}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:46:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145058#M7047</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2020-10-29T08:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145059#M7048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In the issue of pull-ups while set at 10k, I have to say this value is too high it may work at 400KHz but I have experienced that as you star running in real environment, you will loose packets.&amp;nbsp;4.7kOhms is what I have used in the past and&amp;nbsp;achieved 100% success transfer from the Master to&amp;nbsp;the slave and vice versa. If you notice for a 400KHz speed there are only 2 settings to select the proper Setup and Hold settings for your device.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; Someone shared with you that they resorted to a bit banged routine to get things to work correctly and that is fine but that was not necessary specially when the final application will use and interrrupt driven firmware and many events have to be handled in the background.&amp;nbsp;&amp;nbsp;When dealing with polled code you have to make sure you have the correct delay and that you monitor the correct condition flags before writing to the I2C data register.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I also agree that the I2C documentation is only sharing where the control and status registers are place and what their functions are. I also agree that we should have a document explaining how the Phillips specified requirements are implement by the module. There are however, 4 I2C appnotes currently published that are supposed illustrate how one can use the module for communications.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Writen code just illustrates your intentions with the module but do very little to really figure out what&amp;nbsp;is really going on in your MCU. Transfering an entire project&amp;nbsp;to allow&amp;nbsp;us to run it in&amp;nbsp;real system, would allow any of our support engineers to debug efficiently and this is the reason&amp;nbsp;why I have suggested that we discuss in more details and find out what the root cause is. .&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In summary:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;-5k or lower on SDA and SCL, If you need a pullup lower than 4.7K, your system is not properly filtered.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;-I2C interrupt driven Driver should be written to allow the I2C state machine schedule&amp;nbsp;I2C protocol&amp;nbsp;events.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Edgar Saenz.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Sep 2007 04:26:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145059#M7048</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2007-09-29T04:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145060#M7049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello BP,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I agree that 10k pull-up resistors are somewhat on the high side, particularly for a 400kHz clock.&amp;nbsp; However, your posted code indicates that you have a 96kHz clock, and since your capacitive bus loading is likely to be substantially less than the 400pF upper limit for&amp;nbsp;this clock rate, I doubt that this is&amp;nbsp;your current&amp;nbsp;problem.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I did some comparison of your posted code with that shown in AN3291 (for the 9S08GB60 device), and found a difference that might be significant -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;While your code seems excessively circuituous, it would appear to resolve to the following sequence&amp;nbsp;for the transmission of each byte by the master -&lt;/FONT&gt;&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Write byte value to IIC1D.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Wait for TCF flag to become set.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Attempt to clear TCF,&amp;nbsp;ARBL and IICIF read only flags.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Wait for RXAK flag to become set.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;By comparison, the similar code shown within AN3291 (which does not use use IIC&amp;nbsp;interrupt) does the following -&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Write byte value to IIC1D.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Wait for&amp;nbsp;IICIF flag to become set.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Clear the&amp;nbsp;IICIF flag only.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Wait for RXAK flag to become set.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; IIC1D = data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; while (!IIC1S_IICIF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // wait until interrupt flag&lt;BR /&gt;&amp;nbsp;&amp;nbsp; IIC1S_IICIF = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear flag&lt;BR /&gt;&amp;nbsp;&amp;nbsp; while (IIC1S_RXAK);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Wait for ACK from slave&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;So the important aspect appears not that it be necessary to implement interrupts, but that the interrupt flag IICIF should be the flag that is tested and cleared, rather than TCF.&amp;nbsp; If this is correct, the issue&amp;nbsp;appears most likely that the IICIF flag becomes set some time after the TCF flag is set, and the attempt to clear the flags&amp;nbsp;does not clear the IICIF flag (which is obviously a mandatory&amp;nbsp;requirement, although not stated in the data sheet).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The importance of testing the IICIF flag (and not TCF) is suggested by the author of AN3291, in the following thread, that also addresses a bug present in the original release of the application note&amp;nbsp;-&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=3785" target="_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;message.id=3785&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The application note makes no mention of the need for an extra delay following START or STOP conditions.&amp;nbsp; It might have been more instructive if the reason for the previous suggestion of their inclusion was given, in order to appreciate what the magnitude of the delay&amp;nbsp;might be.&lt;/P&gt;&lt;P&gt;Finally, I notice that your code for the generation of START and STOP seems more complex than the application note would suggest -&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; IIC1C_TXAK = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // RX/TX = 1; MS/SL = 1; TXAK = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; IIC1C |= 0x30;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // generate START&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;and&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; IIC1S_IICIF = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear interrupt flag&lt;BR /&gt;&amp;nbsp;&amp;nbsp; IIC1C_MST = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // generate STOP&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mac&lt;BR /&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-09-29&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;03:49 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Sep 2007 12:34:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145060#M7049</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-09-29T12:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145061#M7050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;IICIF flag is the only flag&amp;nbsp;I dealt with in my driver which has polled and interrupts driven utilities.&amp;nbsp;TCF is there as a status flag and is&amp;nbsp;seems&amp;nbsp;to be there to&amp;nbsp;indicate when the Transmission is complete, how that status flag is used in code is still unknow to me but I am sure there is a use for it. The same module is used on the S12s where I did most of my IIC testing, and yes you are correct, the code in polled style works and can be made to run but I found that for any application where the MCUs task is more complicated, Interrupts is the way to go and since everything I get drafted into is not simple, I love Interrupts. You of course do not have to. Sounds to me you have figured it out and thank you for using our devices.&amp;nbsp; It is not that complex to watch the behavior of the device, specially when the using the Debugger under CW, one only needs to set the Memory window in periodic display mode and run the Master to brake and trace on every IICDR statement, or in machine code at STA 0xIICDR. One can see with of the flags are set and clear on each byte transaction. I was hoping you could open an SR so that I can share my un published&amp;nbsp;appnote&amp;nbsp;with&amp;nbsp;you but since you are well on your way. More power to you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Edgar.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Sep 2007 23:35:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145061#M7050</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2007-09-29T23:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145062#M7051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi to all,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you for your interest.&lt;/DIV&gt;&lt;DIV&gt;Here is my last implementation.&lt;/DIV&gt;&lt;DIV&gt;Now I'm living problem only with i2c_getbyte() function.&lt;/DIV&gt;&lt;DIV&gt;It is returning either 0 or holding on at line: while(!IIC1S_IICIF);&lt;/DIV&gt;&lt;DIV&gt;I'm using this function to read sequential bytes.&lt;/DIV&gt;&lt;DIV&gt;Do you know how we exactly start reading sequence?&lt;/DIV&gt;&lt;DIV&gt;Or what&amp;nbsp;are the&amp;nbsp;conditions that cause reading sequence not to start?&lt;/DIV&gt;&lt;DIV&gt;The communication speed is 96Khz with 10Kohm pull-ups and no capacitance. (also tried with 22pF caps without chance)&lt;/DIV&gt;&lt;DIV&gt;My scope&amp;nbsp;is in the service now, I will send some images about SCL and SDA in a few days.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;void i2c_clearflags(void){  IIC1S_IICIF = 1;  IIC1S_TCF = 0;  IIC1S_ARBL = 0;}void i2c_start(void){  i2c_clearflags();    IIC1S_SRW = 0; // master will send data    IIC1C = 0b10111000; // Start, TX, NOACK      Wait_sh(80);}void i2c_stop(void){  i2c_clearflags();  IIC1S_SRW = 0; // master will send data    IIC1C = 0b10000000;    Wait_sh(80);}void i2c_restart(void){  i2c_clearflags();    IIC1S_SRW = 0; // master will send data  IIC1C = 0b10111100; // Start, TX, NOACK, RESTART    Wait_sh(80);}char i2c_waitforflag(void){  IIC1SSTR status;    do  {    status.Byte = IIC1S;  } while(!status.Bits.IICIF);    i2c_clearflags();      return(!status.Bits.RXAK);}char i2c_sendbyte(unsigned char data){  if(IIC1C != 0b10111000) IIC1C = 0b10111000;  IIC1D = data;    return(i2c_waitforflag());}unsigned char i2c_getbyte(char send_ack){  unsigned char data;    if(IIC1C_TX)  {    IIC1C_TX = 0;    IIC1C_TXAK = 0;            data = IIC1D; // initiate first reading sequence  }    while(!IIC1S_IICIF);  i2c_clearflags(); if(send_ack) IIC1C_TXAK = 0;  else IIC1C_TXAK = 1;        data = IIC1D; // read right data    return(data);}&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:46:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145062#M7051</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2020-10-29T08:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145063#M7052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Just to give you and Idea on what it takes to make this module to roll data out without a problem in Poll mode.&lt;/DIV&gt;&lt;DIV&gt;I am using some software semaphores so the code may not be easily portable but I am sharing this code so that you get to see some of what works. This is the same module as the one you are using the bit names have a small modification but it should be simple to make sense of the names. I left most of my comments in the code and I hope they help,.&amp;nbsp; 10K pull up values are going to give you problems. I go for 5Ks if I were you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I avoid do, while statements as they generate brclr/sets and those instructions&amp;nbsp;tend to get stuck depending on the condition required. I always like the routine to return and error code and exit.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ed&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;//*****************************************************************//&lt;BR /&gt;//Inputs: char ID,char Read_Write,char NumberBytes&lt;BR /&gt;//Outputs:&amp;nbsp; IIC_Accepted&lt;/DIV&gt;&lt;DIV&gt;// Calling format : ack_flag=Send_IIC_Address(Control1,RW1,Total_Bytes)&amp;nbsp;&lt;BR /&gt;//*****************************************************************//&lt;BR /&gt;char Send_IIC_Address(char ID,char Read_Write,char NumberBytes)&lt;BR /&gt;{&lt;BR /&gt;char IIC_Accepted;&lt;BR /&gt;IIC_Accepted=0;&lt;BR /&gt;if(Slave_Flag==0)// if driver intends to be in Master mode&lt;BR /&gt;{&lt;BR /&gt;IBIF=1;&lt;BR /&gt;TX_RX_=1; // from master to slave&lt;BR /&gt;MS_SL_=1; // send START on clean slate&lt;BR /&gt;}&lt;BR /&gt;ID=ID&amp;lt;&amp;lt;1;&lt;BR /&gt;if(MS_SL_==1 &amp;amp;&amp;amp; TX_RX_==1)&amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;IIC_Delay(1000000);//spacing between start and char.&lt;BR /&gt;// should not be needed to ensure byte reception&lt;/DIV&gt;&lt;DIV&gt;// continuity.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;if(Packet_Status==0)//&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;IIC_DATA_ARRAY[0]=NumberBytes;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;IIC_Byte_Counter=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Send(ID | Read_Write);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;//IBDR=ID | Read_Write;// or the SRW bit with Address ID.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;//IIC_Delay(100);// worked polled at 900 at 968usec from end of last to begin of next.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// worked polled at 500 at 59usec from ID to first byte.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;if(RXAK==0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;IIC_Accepted=PORTB;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;IIC_Accepted=IIC_Accepted &amp;amp; 0xF7;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;PORTB=IIC_Accepted;// Turn on LED4 to indicate packet is transfer.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(Read_Write==1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Slave_Flag=0;// master mode&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;IIC_Accepted=1;//Everything is cool let's get running&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Packet_Status=1;&amp;nbsp; &amp;nbsp;// handled in the interrupt when polled here&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;else&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;MS_SL_=0;// sending stop&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&amp;nbsp;&lt;BR /&gt;IBEN=0;&lt;BR /&gt;IBEN=1;// Bus is gone crazy&lt;BR /&gt;MS_SL_=1;// sending START&lt;BR /&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;return IIC_Accepted;// if char =0 no response from slave node.&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;**************************************************************************************************************&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;//Description. Send packet will send a series of packets with&lt;BR /&gt;//incremental data n to n-1 where n-1=Number_Bytes-1 bytes.&lt;BR /&gt;char Send_Packet_Polled(char Number_Bytes)&lt;BR /&gt;{// send&lt;BR /&gt;char Byte_Counter=0;&lt;BR /&gt;char error_flag;&lt;BR /&gt;char Return_Val=0;&lt;BR /&gt;char Number_Fail=0;&lt;BR /&gt;char Number_Pass=0;&lt;BR /&gt;char chase_flag=1;&lt;BR /&gt;while(chase_flag==1)&amp;nbsp;&amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;Return_Val=Send_IIC_Address(0x0E,0,4);//wp0xe&lt;BR /&gt;if (Return_Val==1)// good case.&lt;BR /&gt;{&lt;BR /&gt;Number_Pass++;&lt;BR /&gt;chase_flag=false;&lt;BR /&gt;}else&lt;BR /&gt;{&lt;BR /&gt;Number_Fail++;&amp;nbsp;&lt;BR /&gt;Byte_Counter=0;&lt;BR /&gt;return Byte_Counter;// Returns Number_Bytes-1 as completion flag&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;}// end of while char_flag&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;for (Byte_Counter=0;Byte_Counter&amp;lt;=Number_Bytes&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;// working with 7 but no second packet was moved to else.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(IBIF==1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(RXAK==0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//400 456 uSec works on packet only&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//500 568 uSec works&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//600 because START always given a macth hard to code&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(MS_SL_==1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(TX_RX_=1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IIC_Delay(900000);/// could do a while (IBIF==1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IBDR=Byte_Counter;&amp;nbsp;// to generate brclr instruction.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IIC_Delay(60);//100= 56usec working&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 60=10usec spacing between bytes.&amp;nbsp;Real&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Byte_Counter++; // 55=8usec and not working real&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 60 EM does not&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 70 no&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 100&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 200&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Byte_Counter=Number_Bytes+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return Byte_Counter;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}// end of else RXAK==0;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(RXAK==1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;error_flag=1;// abnormal condition&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Byte_Counter=Number_Bytes+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MS_SL_=0;// send stop&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IBIE=0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TX_RX_=1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return Byte_Counter;// Returns Number_Bytes-1 as completion flag&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}// end of if no ack from slave&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}// end of if(IBIF==1) case.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{//&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Byte_Counter = Number_Bytes-1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}// end of if(IBIF==0) case.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// end of good case&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(Byte_Counter == Number_Bytes-1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;error_flag=0;//normal condition&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Byte_Counter=Number_Bytes+1;// end this loop&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;MS_SL_=0;// send stop&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;IBIE=0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;TX_RX_=1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return Byte_Counter;// Returns Number_Bytes-1 as completion flag&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp; }// end of send Number_Bytes polled for loop.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;}// end of send Packet Polled.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 22:18:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145063#M7052</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2007-10-02T22:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145064#M7053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello BP,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Firstly, there seems to be&amp;nbsp;confusion about some of the flags -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;SRW is a read only flag, and is of no interest for master operation.&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="2"&gt;Similarly, the ARBL flag is of no interest with a dedicated master.&amp;nbsp; Anyway, it is cleared by writing 1, not 0.&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="2"&gt;The TCF flag is automatically cleared on the next read or write to IIC1D register.&amp;nbsp;&lt;/FONT&gt; &lt;FONT size="2"&gt;This leaves only the IICIF flag to be concerned about in the flag clearing process.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I don't know why you chose not to use standard bit definitions within the &lt;FONT face="Courier New"&gt;i2c_waitforflag()&lt;/FONT&gt; function.&amp;nbsp; Also, the intention of the line&lt;BR /&gt;&lt;FONT face="Courier New"&gt;return(!status.Bits.RXAK);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;seems obscure.&amp;nbsp; It certainly doesn't wait until the RXAK &amp;nbsp;flag is set.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;You should check the actual requirements in the data sheet for the EEPROM device, but to start the reading sequence, after sending the&amp;nbsp; address bytes, you will probably need to generate a repeated start, and then send the control byte again with the RW bit&amp;nbsp; set for read.&amp;nbsp; Then clear the IIC1C_TX bit for read,&amp;nbsp;set the IIC1C_TXAK bit to disable acknowledge, and do a dummy read of the IIC1D register.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I suggest you examine the left hand part of Fig. 13.1 in the data sheet for the AW60.&amp;nbsp; Even though the flow diagram pertains to an ISR, a similar sequence of events will be required when the flag is polled.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Finally, do not add any capacitors to the bus - the least capacitance the better.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 02:44:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145064#M7053</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-10-03T02:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145065#M7054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;This is a late "thank you much" to PeterHouse for the feedback around 9/18/2007 on AW60 IIC.&amp;nbsp; I just scanned back through here today, and was a bit surprised at how much activity is still on this thread.&amp;nbsp;&amp;nbsp;The length of this total thread alone should tell you something.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Heres my two cents on the polling use of this IIC module on the AW60.&amp;nbsp; IIC is slick for me simply because of the two-wire use. I often use it for passing info across isolation barriers, and doing this with two optos instead of three for SPI is really nice.&amp;nbsp; I often don't actually "bus" anything on it - just one part like a DAC, an&amp;nbsp;LCD, or an EEPROM.&amp;nbsp; However, as Peter said, it truly is a complex module in the AW60 for the few 2-3 bytes of data I jamb through.&amp;nbsp; In my case, running this in interrupt mode&amp;nbsp;really makes no sense, as its far easier to simply wait for the bytes to clear and just move on in my specific application.&amp;nbsp; As I read through several other posts to the thread, I disagree on using interrupts any time just because they are available - if they don't make sense for the application code, then they don't make sense period.&amp;nbsp;&amp;nbsp;In fact, throwing interrupts in everywhere for no good reason is a great way to build a pretty unreliable product.&amp;nbsp; The bit&amp;nbsp;bang routines work best for these mini transfers (they have for over 10 years now on this actual product), so I went back to them after a week of messing around.&amp;nbsp; I had&amp;nbsp;only tried to convert them because the new AW60 processor supported the IIC module. Honestly, I haven't had&amp;nbsp;any problems for last 20 years working with simple bit-bang IIC implementations like this on&lt;BR /&gt;Mot/Freescale/TI/etc processors until I&amp;nbsp;recently started playing with this AW60 module.&amp;nbsp; I'm a big fan of&amp;nbsp;Freescale parts, and I was pretty disappointed this wouldn't work out.&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I find it odd sometimes in this forum when something clearly doesn't work in its basic described format, that the Freescale factory support is&amp;nbsp;more of a debate on how a different approach certainly must be taken (ie. "don't run it in polling mode because it doesn't make any sense to do that when the code will be full of interrupts anyway")&amp;nbsp; What?&amp;nbsp; In this case, if the module&amp;nbsp;contains proper flags to support&amp;nbsp;simple monitoring of when data bytes clear (and it does), then it should work that way&amp;nbsp;regardless of whether or not some other interrupt is running.&amp;nbsp; If not, maybe we need a errata to tell us what is going on.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks much to all the actual users out there like Peter that support this forum, and make it invaluable to all of us up in the middle of the night trying to sort these things out.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2007 12:09:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145065#M7054</guid>
      <dc:creator>JMAC</dc:creator>
      <dc:date>2007-10-13T12:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145066#M7055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hello JMAC,&lt;BR /&gt;&lt;BR /&gt;"Freescale Factory Support" was NOT involved in this thread.&lt;BR /&gt;"Factory Support" is a special term used in supporting world which means L4 or 4th line.&lt;BR /&gt;&lt;BR /&gt;Being "Freescaler" means being part of the company and wanting to help. The person could be less specialist than some 'external' members... But I would not refuse help as it gives another light on the matter.&lt;BR /&gt;&lt;BR /&gt;In this case, the Freescaler who replied is knowledgable and see a lot of questions.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For very specific applications, interrupts are forbidden because the exact path of execution is required to be known. This is usually the case in safety critical systems. That is probably why polling is still offered.&lt;BR /&gt;With the growing number of features required and the always growing abilities to test better, the number of applications forbidding the use of interruption is falling.&lt;BR /&gt;&lt;BR /&gt;As an example, MAGGALY an automatic subway was only made of logic, because there was a probability of 0.000001 of any microprocessor to crash (I don't know the odds now).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I would still advise you to use the interrupt driven mechanism...&lt;BR /&gt;&lt;BR /&gt;Alban.&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 15:09:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145066#M7055</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2007-10-15T15:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145067#M7056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;One of the reasons why I do not particularly prefer forums is that is very hard to follow the trend of thought and I do not know if the person who was having the problem is now okay.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am one of the&amp;nbsp;IIC experts at the factory, my claim&amp;nbsp;to fame is that I have actually been the only one that has gone inside the IIC module and traced signals through the logic module&amp;nbsp;at the Failure Analysis Lab. A project that thought me a lot about what IIC is and what the strengths and weaknesses are. I also exercised the module, polled and interrupt driven to understands hung ups and LOAs and why they were happening in our development tools and for some big European Customers. I am now working for the TechnicalInformationCenter and support mainly the US market but have not problems helping anyone who is having problems with the module.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;IIC is not an easy byte protocol and it is even harder to implement at packet protocol but&amp;nbsp;the task&amp;nbsp;is very attainable. I will encourage anybody who is implementing a true IIC bus to open up a service request at &lt;A href="http://www.freescale.com/" rel="nofollow" target="_blank"&gt;www.freescale.com&lt;/A&gt; and request the issue to be assigned to me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have since written an IIC appnote which I abandoned due to the fact that they were many others in progress so I thought that duplicating efforts would not be the best thing for me. However, you are correct, TCF is a status bit, I never had to use. I started out with the notion that this control bit would act like a completion flag on an Analog to Digital converter but I was wrong and when I ran simulations the TCF is used but it be may only a test mode feature. Since I was under the gun at the time, I never went back to get the real story on what its functionality really is. Sorry for the inconvenience that caused you.&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;SPAN&gt;Hi BP,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Your assumption about load capacitance versus speed is incorrect but the concept is right on. The slower the speed under a heavy capacitance&amp;nbsp;load the more of a slew rate affects the IIC bus performance and the more LOAs I experienced, I know why this happens but it would take me more than 3000 chars to explain it. The solution to bus hang ups is to make the rise and fall times of the clock and data as fast as possible.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Edgar Saenz.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Technical&lt;/SPAN&gt;&lt;SPAN&gt;InformationCenter&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;16 bit Team leader.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 22:38:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145067#M7056</guid>
      <dc:creator>Fonsi</dc:creator>
      <dc:date>2007-10-15T22:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145068#M7057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;i'm using the AW32 I2C module, implementing a master only C code with interrupts. I drive a PCF8570 I2C RAM at 89khz with 4,7K pullups, at&amp;nbsp;less than 5 cm distance on the board. For information, i use this RAM only to save data with a backup battery when the power is off. The main reason is that i couldn't get accurate information on the way to backup directly the AW32 RAM (very basic topic, yes...but the support is still working on it). But it's another story.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I started my I2C integration today, and of course, nothing works. At reset, the SDA, SCL lines are&amp;nbsp;high, and after using my write routine for the 1st time, both still at low forever.&lt;/DIV&gt;&lt;DIV&gt;I used a step by step execution in the write routine. The lines are high up to arrive at the START condition. At master selection (ie START or IIC1C_MST = 1), both pins goes and still low. No data out,&amp;nbsp;&amp;nbsp;and the interrupt never comes.&amp;nbsp;It occurs also when i remove the PCF8570 .&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier" size="1"&gt;IIC1C_TX = 1; /* Select Transmit Mode */&lt;/FONT&gt;&lt;/DIV&gt;&lt;P align="left"&gt;IIC1C_MST = 1; /* &amp;lt;&amp;lt;&amp;lt;&amp;lt; problem occurs here&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Send Start) */&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;//for(T=0;T&amp;lt;10;T++);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Small delay */&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;SCI1D = iicport_1.IICaddr;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* write address to start transmission */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I tried various SW combinations using the HS08 docs (peripheral module quick reference, ...) but&amp;nbsp;no change.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I think, by reading this forum, that there is a HW bug somewhere. I'll send a service request.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Bye&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2007 04:02:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145068#M7057</guid>
      <dc:creator>joemanix</dc:creator>
      <dc:date>2007-10-27T04:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: AW32: I2C Problem</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145069#M7058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I've been working on a similar problem - AW60, polled I2C. Here's what I found I needed to to to get it to work:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Immediately after setting IIC1C for the transfer, clear the interrupt flag (bset #1,IIC1S) - before writing the address byte to IIC1D&lt;/DIV&gt;&lt;DIV&gt;When writing to IIC1D, wait at least 12 clock cycles (jsr to a return) before brclr #1,IIC1S,*&lt;/DIV&gt;&lt;DIV&gt;When reading from IIC1D, wait at least 12 clock cycles between clearing the interrupt flag (bset #1,IIC1S) and reading the IIC1D register&lt;/DIV&gt;&lt;DIV&gt;After waiting for&amp;nbsp;#0,IIC1S when transitioning from read to write mode, wait 12 cycles between each operation. Same thing when disabling ACK for the last transfer.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Wait for #0,IIC1S&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Wait 12 Tcyc&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Set IIC1C for write mode&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Wait 12 Tcyc&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Read IIC1D&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Wait 12 Tcyc&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; Wait for #1,IIC1S&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Clear #1,IIC1S&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This seems to have worked for me. Hope it helps someone out there. I write in assembly code so perhaps C compilers put in the little delays just because. Anyways, it appears to work properly now.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2008 11:47:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AW32-I2C-Problem/m-p/145069#M7058</guid>
      <dc:creator>DaleUlan</dc:creator>
      <dc:date>2008-04-11T11:47:32Z</dc:date>
    </item>
  </channel>
</rss>

