<?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: Programming I2C module on mCF5485 in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205725#M9731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; How do I address I2FDR? How so I set the I2FDR to a particular value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your development environment sure have either&lt;/P&gt;&lt;P&gt;(case 1)&amp;nbsp;define or&lt;/P&gt;&lt;P&gt;(case 2)&amp;nbsp;C structure, which allows&amp;nbsp;access to any register of a peripheral controller.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first case, you where the&amp;nbsp;ready-made define of I2FDR symbol is available, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; volatile BYTE * pI2FDR = I2FDR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *pI2FDR = 0x36;&lt;/P&gt;&lt;P&gt;In second case, where&amp;nbsp;I2FDR is available as&amp;nbsp;part of the C structure, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; sim.i2c.fdr = 0x36;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; Will I2FDR = 0x36 work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, if your development environment has define similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; #define I2FDR (sim.i2c.fdr)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; I want the clock frequency to be 400KHz. Should I set I2FDR with 0x36 or 0x37?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which internal bus clock do you have?&lt;/P&gt;&lt;P&gt;For example, mcf5270 with core (system)&amp;nbsp;clock Fsys=147.456 MHz, the calculated divider is&lt;/P&gt;&lt;P&gt;&amp;nbsp; IC = (Fsys/2)/Fsck = (147.456 MHz) / 2 / (0.4 MHz) = 184.32&lt;/P&gt;&lt;P&gt;Thus, the nearest integer value of the divider, which&amp;nbsp;results in Fsck&amp;lt;=400 kHz, is 185.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN class="Apple-style-span"&gt;set I2CR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; question : How do I address single bit in this register? I want the processor to be in Master mode,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; it will receive data from I2C device.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first case, where the&amp;nbsp;ready-made define of I2FDR symbol is available. You can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; volatile BYTE * pI2CR = I2CR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *pI2CR |= 0x20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In second case, where&amp;nbsp;I2CR is available as&amp;nbsp;part of the C structure, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; sim.i2c.cr |= 0x20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; But while transmitting device address, does the processor need to be in transmitter mode and then switch to receiver mode?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;In i2c protocol, transmit and receive are physically simultaneous.&amp;nbsp;But, most of i2c libraries send START condition together with SLAVE_ADDRESS word by calling transmit_slave_address() function, and receive the data from the slave by receive_slave_data() function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN class="Apple-style-span"&gt;What about acknowledge signal? Do i have to generate it every time or it is generated automatically?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;To transmit&amp;nbsp; the acknowledge bit, you need bit I2CR[TXAK] be zero before or simuntaneously with setting bit I2CR[MSTA].&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; question: Do i need to set and clear any flag/bit from I2SR while reading data from I2DR?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;No. But, you need verify I2SR[IBB]=0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; Am I right about the above procedure? if not please let me know the correct procedure.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN class="Apple-style-span"&gt;See examples in the Reference Manual.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Aug 2009 15:15:59 GMT</pubDate>
    <dc:creator>admin</dc:creator>
    <dc:date>2009-08-11T15:15:59Z</dc:date>
    <item>
      <title>Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205724#M9730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Hello, I am trying to connect an I2C device to the MCF5485. I want to read data from the device. Basically i want to write a device driver for that device. I have read the reference manual of the processor. I have inferred the following:The processor should be in master mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;First I need to initialize the I2C module.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;set correct value in I2FDR for SCL.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;question: How do I address I2FDR? How so I set the I2FDR to a particular value?Will I2FDR = 0x36 work? I want the clock frequency to be 400KHz. Should I set I2FDR with 0x36 or 0x37?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;set I2CR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;question : How do I address single bit in this register? I want the processor to be in Master mode, it will receive data from I2C device. But while transmitting device address, does the processor need to be in transmitter mode and then switch to receiver mode? What about acknowledge signal? Do i have to generate it every time or it is generated automatically?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Do dummy read of I2DR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;set I2SR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;start reading data from I2DR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;question: Do i need to set and clear any flag/bit from I2SR while reading data from I2DR?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Am I right about the above procedure? if not please let me know the correct procedure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Rohit&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2009 01:19:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205724#M9730</guid>
      <dc:creator>rgirme</dc:creator>
      <dc:date>2009-08-07T01:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205725#M9731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; How do I address I2FDR? How so I set the I2FDR to a particular value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your development environment sure have either&lt;/P&gt;&lt;P&gt;(case 1)&amp;nbsp;define or&lt;/P&gt;&lt;P&gt;(case 2)&amp;nbsp;C structure, which allows&amp;nbsp;access to any register of a peripheral controller.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first case, you where the&amp;nbsp;ready-made define of I2FDR symbol is available, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; volatile BYTE * pI2FDR = I2FDR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *pI2FDR = 0x36;&lt;/P&gt;&lt;P&gt;In second case, where&amp;nbsp;I2FDR is available as&amp;nbsp;part of the C structure, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; sim.i2c.fdr = 0x36;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; Will I2FDR = 0x36 work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, if your development environment has define similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; #define I2FDR (sim.i2c.fdr)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; I want the clock frequency to be 400KHz. Should I set I2FDR with 0x36 or 0x37?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which internal bus clock do you have?&lt;/P&gt;&lt;P&gt;For example, mcf5270 with core (system)&amp;nbsp;clock Fsys=147.456 MHz, the calculated divider is&lt;/P&gt;&lt;P&gt;&amp;nbsp; IC = (Fsys/2)/Fsck = (147.456 MHz) / 2 / (0.4 MHz) = 184.32&lt;/P&gt;&lt;P&gt;Thus, the nearest integer value of the divider, which&amp;nbsp;results in Fsck&amp;lt;=400 kHz, is 185.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN class="Apple-style-span"&gt;set I2CR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; question : How do I address single bit in this register? I want the processor to be in Master mode,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; it will receive data from I2C device.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first case, where the&amp;nbsp;ready-made define of I2FDR symbol is available. You can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; volatile BYTE * pI2CR = I2CR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *pI2CR |= 0x20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In second case, where&amp;nbsp;I2CR is available as&amp;nbsp;part of the C structure, you can use similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; sim.i2c.cr |= 0x20;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; But while transmitting device address, does the processor need to be in transmitter mode and then switch to receiver mode?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;In i2c protocol, transmit and receive are physically simultaneous.&amp;nbsp;But, most of i2c libraries send START condition together with SLAVE_ADDRESS word by calling transmit_slave_address() function, and receive the data from the slave by receive_slave_data() function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN class="Apple-style-span"&gt;What about acknowledge signal? Do i have to generate it every time or it is generated automatically?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;To transmit&amp;nbsp; the acknowledge bit, you need bit I2CR[TXAK] be zero before or simuntaneously with setting bit I2CR[MSTA].&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; question: Do i need to set and clear any flag/bit from I2SR while reading data from I2DR?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;No. But, you need verify I2SR[IBB]=0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt; Am I right about the above procedure? if not please let me know the correct procedure.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN class="Apple-style-span"&gt;See examples in the Reference Manual.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2009 15:15:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205725#M9731</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2009-08-11T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205726#M9732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correction:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt; &lt;SPAN class="Apple-style-span"&gt;What about acknowledge signal? Do i have to generate it every time or it is generated automatically?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN class="Apple-style-span"&gt;To transmit&amp;nbsp; the acknowledge bit during read from the slave, you need bit I2CR[TXAK] be zero before reading I2DR.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2009 16:00:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205726#M9732</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2009-08-11T16:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205727#M9733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;&lt;SPAN&gt;@&lt;A href="http://forums.freescale.com/freescale/view_profile?user.id=9363" target="_blank"&gt;yevgenit&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you...your reply helped me figure out many things...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2009 02:07:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205727#M9733</guid>
      <dc:creator>rgirme</dc:creator>
      <dc:date>2009-08-12T02:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205728#M9734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="Apple-style-span"&gt;Hi, I have installed Linux on my board, hence I cannot access the processor registers directly from user space. So I am using the /dev interface. Here is my new code. I can open the I2C device and set the slave address. But when I try to read/write to the device, I get an error. Also how do I change the frequency of the I2C clock? Please help me out..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;BR /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;BR /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/ioctl.h&amp;gt;&lt;BR /&gt;&lt;BR /&gt;#include &amp;lt;linux/i2c.h&amp;gt;&lt;BR /&gt;#include&amp;lt;linux/i2c-dev.h&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int filep;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int addrs = 0x52;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char buff[1];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct i2c_msg msg;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct i2c_rdwr_ioctl_data ptr;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((filep = open("/dev/i2c-0", O_RDWR)) &amp;lt; 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nCould not open device ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nI2C Device opened ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((ioctl(filep, I2C_SLAVE, addrs)) &amp;lt; 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nCould not set slave address ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nSlave Address set ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char res = 0x40;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char buffer[3];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer[0] = res;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer[1] = 0x00;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer[2] = 0x01;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;10;i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(write(filep, buffer, 3) != 3)&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;&amp;nbsp;&amp;nbsp; printf("Write Failed ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;10;i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; buff[0] = 0x40;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.addr = addrs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.flags = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.len = 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.buf = buff;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ptr.msgs = &amp;amp;msg;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if((ioctl(filep, I2C_RDWR, addrs)) &amp;lt; 0)&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;&amp;nbsp;&amp;nbsp; printf("\nCould not write to slave ..");&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;&amp;nbsp; exit(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; 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; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nWrite Successful ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buff[0] = 0x00;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg.addr = addrs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg.flags = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg.len = 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg.buf = buff;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptr.msgs = &amp;amp;msg;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((ioctl(filep, I2C_RDWR, addrs)) &amp;lt; 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nCould not write to slave ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\nWrite Successful ..");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 04:32:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205728#M9734</guid>
      <dc:creator>rgirme</dc:creator>
      <dc:date>2009-08-14T04:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Programming I2C module on mCF5485</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205729#M9735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://forums.freescale.com/freescale/view_profile?user.id=14934" target="_blank"&gt;&lt;SPAN&gt;rgirme&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;, I am not familiar with your Linux driver, but any I2C driver must have API to configure clock speed and other properties. Try to find such a functionality at files&amp;nbsp;linux/i2c.h and linux/i2c-dev.h&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 10:51:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Programming-I2C-module-on-mCF5485/m-p/205729#M9735</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2009-08-14T10:51:48Z</dc:date>
    </item>
  </channel>
</rss>

