<?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: K60 I2C alternate function in board TWR-K60N512 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196138#M2640</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response. I am still facing some problem with I2C write . Below is the piece of code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setup_I2C();&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; /* Open the I2C driver, and assign a I2C device handler */&lt;BR /&gt;&amp;nbsp; fd = fopen ("ii2c0:", NULL);&lt;BR /&gt;&amp;nbsp; if (fd == NULL)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Failed to open the I2C driver!\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _time_delay (200L);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mqx_exit (1L);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; /* Set I2C into Master mode */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_MASTER_MODE, NULL);&lt;BR /&gt;&amp;nbsp; /* Set the destination address */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, &amp;amp;ltc_i2c_slave_adr);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;_time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Write 2 bytes of data: the desired register and then the data */&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; result = fwrite (&amp;amp;val, 1, 2, fd);&amp;nbsp; //data to write, size of unit, # of bytes to write, I2C device handler&lt;BR /&gt;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; fflush (fd);&lt;BR /&gt;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; if (result == 0)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Write FAILED! with %d\n", result);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("OK - Sent: %d bytes of 0x%08x\n", result, param);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; //ioctl (fd, IO_IOCTL_FLUSH_OUTPUT, NULL);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;// _time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Send out stop */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_STOP, NULL);&lt;BR /&gt;&amp;nbsp; fclose(fd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to send the start and slave address using i2c bus which i can see in logic analyzer&amp;nbsp; , but i2c data write fails. I2C write API fwrite fails which returns 0. Is anything wrong in the code I used. Attached is the waveform snapshot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haresha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Jan 2012 14:06:49 GMT</pubDate>
    <dc:creator>Suvarna</dc:creator>
    <dc:date>2012-01-09T14:06:49Z</dc:date>
    <item>
      <title>K60 I2C alternate function in board TWR-K60N512</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196136#M2638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working freescale board TWR-K60N512. I am trying to write I2 driver for kinetics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the piece of code for I2C alternate function in board TWR-K60N512&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Clock gate&lt;BR /&gt;&amp;nbsp; SIM_SCGC4 |= SIM_SCGC4_I2C0_MASK;&lt;BR /&gt;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; PORTD_PCR8 &amp;amp;= ~PORT_PCR_MUX_MASK;&lt;BR /&gt;&amp;nbsp; PORTD_PCR8 |= PORT_PCR_MUX(2); //I2C0SCL&lt;BR /&gt;&amp;nbsp; PORTD_PCR9 &amp;amp;= ~PORT_PCR_MUX_MASK;&lt;BR /&gt;&amp;nbsp; PORTD_PCR9 |= PORT_PCR_MUX(2); //I2C0SDA&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; _ki2c_int_install("ii2c0:", &amp;amp;_bsp_i2c0_init).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this mapping is right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,'&lt;/P&gt;&lt;P&gt;Hareesha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 16:36:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196136#M2638</guid>
      <dc:creator>Suvarna</dc:creator>
      <dc:date>2012-01-07T16:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: K60 I2C alternate function in board TWR-K60N512</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196137#M2639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hareesha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The mapping looks good - the pins should however also be configured as open-drain with (optional) pull-up resistor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2012 03:35:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196137#M2639</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2012-01-08T03:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: K60 I2C alternate function in board TWR-K60N512</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196138#M2640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response. I am still facing some problem with I2C write . Below is the piece of code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setup_I2C();&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; /* Open the I2C driver, and assign a I2C device handler */&lt;BR /&gt;&amp;nbsp; fd = fopen ("ii2c0:", NULL);&lt;BR /&gt;&amp;nbsp; if (fd == NULL)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Failed to open the I2C driver!\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _time_delay (200L);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mqx_exit (1L);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; /* Set I2C into Master mode */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_MASTER_MODE, NULL);&lt;BR /&gt;&amp;nbsp; /* Set the destination address */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, &amp;amp;ltc_i2c_slave_adr);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;_time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Write 2 bytes of data: the desired register and then the data */&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; result = fwrite (&amp;amp;val, 1, 2, fd);&amp;nbsp; //data to write, size of unit, # of bytes to write, I2C device handler&lt;BR /&gt;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; fflush (fd);&lt;BR /&gt;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; if (result == 0)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Write FAILED! with %d\n", result);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("OK - Sent: %d bytes of 0x%08x\n", result, param);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; //ioctl (fd, IO_IOCTL_FLUSH_OUTPUT, NULL);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;// _time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Send out stop */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_STOP, NULL);&lt;BR /&gt;&amp;nbsp; fclose(fd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to send the start and slave address using i2c bus which i can see in logic analyzer&amp;nbsp; , but i2c data write fails. I2C write API fwrite fails which returns 0. Is anything wrong in the code I used. Attached is the waveform snapshot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haresha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2012 14:06:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196138#M2640</guid>
      <dc:creator>Suvarna</dc:creator>
      <dc:date>2012-01-09T14:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: K60 I2C alternate function in board TWR-K60N512</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196139#M2641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know the code that you use - if it is iunterrupt driven I suspect that the interrupts are not enabled since there is no data after the I2C address is sent (which is also acknowledged).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The I2C interface that I use is here: &lt;A href="http://www.utasker.com/docs/uTasker/uTaskerIIC.PDF" rel="nofollow" target="_blank"&gt;http://www.utasker.com/docs/uTasker/uTaskerIIC.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2012 19:40:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196139#M2641</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2012-01-09T19:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: K60 I2C alternate function in board TWR-K60N512</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196140#M2642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. I am able to send the data in polled mode. But actual data is not sent, event address sent is wrong. Instead of 0x20 something else is sent. Data sending stopped after sending 1 byte , it supposed to send 3 byte&lt;/P&gt;&lt;P&gt;Am I using correct write API. Below is the piece of code&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;setup_I2C();&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; _time_delay (1L);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; /* Open the I2C driver, and assign a I2C device handler */&lt;BR /&gt;&amp;nbsp; fd = fopen ("i2c0:", NULL);&lt;BR /&gt;&amp;nbsp; if (fd == NULL)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Failed to open the I2C driver!\n");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _time_delay (200L);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _mqx_exit (1L);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; /* Set I2C into Master mode */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_MASTER_MODE, NULL);&lt;BR /&gt;&amp;nbsp; /* Set the destination address */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_SET_DESTINATION_ADDRESS, &amp;amp;ltc_i2c_slave_adr);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;_time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Write 2 bytes of data: the desired register and then the data */&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; result = fwrite (&amp;amp;param, 1, 3, fd);&amp;nbsp; //data to write, size of unit, # of bytes to write, I2C device handler&lt;BR /&gt;&amp;nbsp;// result = write(fd,&amp;amp;val, 2);&lt;BR /&gt;&amp;nbsp; fflush (fd);&lt;BR /&gt;&amp;nbsp; _time_delay (3L);&lt;BR /&gt;&amp;nbsp; if (result == 0)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("Write FAILED! with %d\n", result);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf ("OK - Sent: %d bytes of 0x%08x\n", result, param);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; //ioctl (fd, IO_IOCTL_FLUSH_OUTPUT, NULL);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; //_time_delay (1L);&lt;BR /&gt;&amp;nbsp; /* Send out stop */&lt;BR /&gt;&amp;nbsp; ioctl (fd, IO_IOCTL_I2C_STOP, NULL);&lt;BR /&gt;&amp;nbsp; fclose(fd);&lt;BR /&gt;&lt;BR /&gt;Attached is the snapshot&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;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2012 20:17:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-I2C-alternate-function-in-board-TWR-K60N512/m-p/196140#M2642</guid>
      <dc:creator>Suvarna</dc:creator>
      <dc:date>2012-01-09T20:17:31Z</dc:date>
    </item>
  </channel>
</rss>

