<?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 Re: I2C Problems in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177358#M12513</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Murele!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I seen that you choosed a wrong &amp;nbsp;SCL divider during your IIC initialisation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dec 64 seems to be not allowed as SCL divider. Please take a look in the Datasheet for&lt;/P&gt;&lt;P align="left"&gt;MC9S08AW60, MC9S08AW48, MC9S08AW32, MC9S08AW16 Rev 2 12/2006 on page 220 and 221.&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;Calculate the IIC Baudrate as follows&lt;/P&gt;&lt;P&gt;IIC baud rate = bus speed (Hz) / (mul x SCL divider)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jul 2012 12:26:48 GMT</pubDate>
    <dc:creator>Ingo_Michael</dc:creator>
    <dc:date>2012-07-13T12:26:48Z</dc:date>
    <item>
      <title>I2C Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177357#M12512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I made a programm for the MC9S08AW32 to read the temperature of a LM92. I send the first byte and then i got the Acknowledge. Then I send the second byte but then i don't get the second acknowledge. Does somebody know why this doesn't work?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2012 02:34:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177357#M12512</guid>
      <dc:creator>Murmele</dc:creator>
      <dc:date>2012-07-05T02:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177358#M12513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Murele!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I seen that you choosed a wrong &amp;nbsp;SCL divider during your IIC initialisation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dec 64 seems to be not allowed as SCL divider. Please take a look in the Datasheet for&lt;/P&gt;&lt;P align="left"&gt;MC9S08AW60, MC9S08AW48, MC9S08AW32, MC9S08AW16 Rev 2 12/2006 on page 220 and 221.&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;Calculate the IIC Baudrate as follows&lt;/P&gt;&lt;P&gt;IIC baud rate = bus speed (Hz) / (mul x SCL divider)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good Luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 12:26:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177358#M12513</guid>
      <dc:creator>Ingo_Michael</dc:creator>
      <dc:date>2012-07-13T12:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177359#M12514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The baud rate divisor setting of 0xBF will set the divisor to 4*3840 = 15360.&amp;nbsp; Since the minimum allowable clock rate for the LM92 is 1kHz, this setting&amp;nbsp;is potentially&amp;nbsp;problematic for a MCU bus frequency below 15.36 MHz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure of the position&amp;nbsp;in the sequence&amp;nbsp;where you perceive that there is a problem.&amp;nbsp; The IIC sequence to read a 16-bit register value should be as follows -&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Set master transmit mode &amp;amp; generate START&lt;/LI&gt;&lt;LI&gt;Send LM92 address, write mode - &lt;FONT color="#ff0000"&gt;error exit if no ACK from slave&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;Send register pointer value ( zero for temperature register) - &lt;FONT color="#ff0000"&gt;error exit if no ACK from slave&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;Generate repeat START&lt;/LI&gt;&lt;LI&gt;Send LM92 address, read mode - &lt;FONT color="#ff0000"&gt;error exit if no ACK from slave&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;Set master receive mode, with ACK returned to slave after next transfer&lt;/LI&gt;&lt;LI&gt;Discard&amp;nbsp;garbage read value - start read transfer for MS data byte&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#ff0000"&gt;Set master receive mode, with no ACK returned to slave after next transfer&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;Read MS byte of returned data and store - start read transfer for LS data byte&lt;/LI&gt;&lt;LI&gt;Generate STOP&lt;/LI&gt;&lt;LI&gt;Read LS byte of returned data and store&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is very difficult to read, but&amp;nbsp;may be deficient in the above marked areas.&amp;nbsp; If an ACK error is detected, a STOP should be generated so as to release the bus.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code snippet demonstrates how to improve&amp;nbsp;code readability and efficiency.&amp;nbsp; The original code, shown first,&amp;nbsp;requires 18 bytes of code.&amp;nbsp; This occurs in numerous places.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lda&amp;nbsp;&amp;nbsp; #ADRESS_SLAVE_WRITE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sta&amp;nbsp;&amp;nbsp; IIC1D&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NoInterrupt_pending&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brset&amp;nbsp;1,IIC1S,Interrupt_pending&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jmp&amp;nbsp;&amp;nbsp; NoInterrupt_pending&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Interrupt_pending&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bset&amp;nbsp; 1,IIC1S&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NACK_4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brclr 0,IIC1S,ACK_4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jmp&amp;nbsp;&amp;nbsp; NACK_4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;ACK_4&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This code could be directly replaced as follows, and would require smaller code (11 bytes).&amp;nbsp; The previously&amp;nbsp;used&amp;nbsp;jump instructions are unnecessary.&amp;nbsp; Maybe you&amp;nbsp;were thinking of PIC branching limitations that do not apply here?&amp;nbsp; With bit manipulation and bit&amp;nbsp;test operations, the individual bits should always be named, to provide readability.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MOV&amp;nbsp;&amp;nbsp;&amp;nbsp; #ADRESS_SLAVE_WRITE,IIC1D&amp;nbsp;; Start data transfer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BRCLR&amp;nbsp; IIC1S_IICIF,IIC1S,*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Wait until flag is set&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BSET&amp;nbsp;&amp;nbsp;&amp;nbsp;IIC1S_IICIF,IIC1S&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; ; Clear flag&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color="#ff0000"&gt;BRSET&amp;nbsp; IIC1S_RXAK,IIC1S,*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; This does not provide an error exit&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The last instruction above would then need to be altered to provide error exit -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BRSET&amp;nbsp; IIC1S_RXAK,IIC1S,ERROR&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;Error exit if no ACK from slave&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2012 19:15:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/I2C-Problems/m-p/177359#M12514</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-07-17T19:15:30Z</dc:date>
    </item>
  </channel>
</rss>

