<?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>S12 / MagniV MicrocontrollersのトピックRe: I2C baud rate and slave address problem</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141272#M3250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I was under the impression that I2C was the protocol for rs485.&lt;BR /&gt;I you would please point me in the direction of rs485 documentation, it would be greatly appreciated.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Jun 2006 22:40:07 GMT</pubDate>
    <dc:creator>rdelljh</dc:creator>
    <dc:date>2006-06-28T22:40:07Z</dc:date>
    <item>
      <title>I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141270#M3248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to communicate with a NSC200 motion controller using the RS485 on the Wytec Dragon 12 board. From the NSC200 manual the baud rate needs to be 19200. using the SCL divider equation I get 24MHZ/19200 = 1250 which doesnt match up with any numbers in the I2C block guide. So I picked 1280 w/ IBFD as $35. I chose $1 for the slave address of the NSC200. I can not get an acknowledgment from the NSC200, just a "No Ack" on my lcd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "c:\egnu092\include\hcs12.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "c:\egnu092\include\vectors12.h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "c:\egnu092\include\delay.c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#include "c:\egnu092\include\lcd_util_dragon12.c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;char *version = "1VE?";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char *home = "1OR";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char *NoAck = "Fail Ack";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;char receive[7];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void openI2C(char ibc, char i2c_ID);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char sendCommand(char *ptr, char ID);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char readData();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void sendSlaveID (char cx);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void displayRead(void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void displayError(void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int main (void){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;openlcd();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;openI2C(0x35,0xFE); /* set I2C baud rate to 19200Hz */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//openI2C(0x00,0xA0); // input from freescale an2318sw&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sendCommand(home,0x10); //move controller to home position&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//sendCommand(version,0x10); /*request to receive controller version*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//readData();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//displayRead();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void openI2C(char ibc, char i2c_ID){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR |= IBEN; /* enable I2C module */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBFD = ibc; /* configure I2C clock rate */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBAD = i2c_ID;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR &amp;amp;= ~IBIE; /* disable I2C interrupt */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR |= IBSWAI; /* disable I2C in wait mode */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void sendSlaveID (char cx){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while (IBSR&amp;amp;IBB); /* wait until I2C bus is idle */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR |= TXRX+MSSL; /* generate a start condition */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBDR = cx; //send out the slave address with R/W bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR &amp;amp; IBIF)); //wait for address transmission to complete&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR &amp;amp;= IBIF; /* clear IBIF flag */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;char readData(){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char i, temp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sendSlaveID(0x10); //generate a start condition and send NSC200*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (IBSR&amp;amp;RXAK)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;displayError();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR |= RSTA; /* generate a restart condition */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBDR = 0x11; /* send ID and set R/W flag to read */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR &amp;amp; IBIF));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR = IBIF;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (IBSR&amp;amp;RXAK)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;displayError(); //if NSC200 did not respond, return error code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR &amp;amp;= ~(TXRX+TXAK); /* prepare to receive and acknowledge */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;temp = IBDR; /* a dummy read to trigger 9 clock pulses */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for (i = 0; i 5; i++) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR &amp;amp; IBIF)); /* wait for a byte to shift in */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR = IBIF; /* clear the IBIF flag */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;receive[i] = IBDR; /* save the current time in buffer */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;} /* also initiate the next read */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR &amp;amp; IBIF)); /* wait for the receipt of receive[5] */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR = IBIF;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR |= TXAK; /* not to acknowledge receive[6] */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;receive[5] = IBDR; /* save receive[5] and initiate next read */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR &amp;amp; IBIF));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR = IBIF;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBCR &amp;amp;= ~MSSL; /* generate stop condition */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;receive[6] = IBDR;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;char sendCommand(char *ptr, char ID){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;char i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sendSlaveID(0x10); /* send ID to NSC200 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if(IBSR &amp;amp; RXAK) /* did NSC200 acknowledge? */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;displayError();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for(i = 3; i &amp;gt;= 0; i--) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBDR = *(ptr+i);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while(!(IBSR&amp;amp;IBIF));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IBSR = IBIF;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if(IBSR &amp;amp; RXAK)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;displayError();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void displayRead(void){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cmd2lcd(0x83); /* set cursor to row 1 column 3 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;puts2lcd(receive);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//cmd2lcd(0xC3); /* set cursor to row 2 column 3 */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void displayError(void){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cmd2lcd(0x83);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;puts2lcd(NoAck);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rdelljh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2006 13:45:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141270#M3248</guid>
      <dc:creator>rdelljh</dc:creator>
      <dc:date>2006-06-28T13:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141271#M3249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I'm confused. If the NSC200 needs RS485 then what does that have to do with I2C? The protocols are not even close.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2006 21:04:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141271#M3249</guid>
      <dc:creator>imajeff</dc:creator>
      <dc:date>2006-06-28T21:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141272#M3250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I was under the impression that I2C was the protocol for rs485.&lt;BR /&gt;I you would please point me in the direction of rs485 documentation, it would be greatly appreciated.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2006 22:40:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141272#M3250</guid>
      <dc:creator>rdelljh</dc:creator>
      <dc:date>2006-06-28T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141273#M3251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I still cant find mention of rs485 in motorola or freescale documentation. I see JK1 the port I'm using on page 3 of the dragon 12 schematic. I also see J18, what should the jumpers be on J18?&lt;BR /&gt;Is SPI the protocol for rs485?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2006 22:55:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141273#M3251</guid>
      <dc:creator>rdelljh</dc:creator>
      <dc:date>2006-06-28T22:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141274#M3252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I apologize for my misuse of word protocol.&lt;BR /&gt;Assuming that the SPI is for rs485 (4pins), I am still having difficultly reconciling the baudrate. The NSC200 needs 19200&lt;BR /&gt;if I take 24MHz/19200 = 1250 which doesnt match up w/ a SPI module clock divisor.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2006 23:19:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141274#M3252</guid>
      <dc:creator>rdelljh</dc:creator>
      <dc:date>2006-06-28T23:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141275#M3253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, rdelljh:&lt;BR /&gt;&lt;BR /&gt;You need to use the SCI for RS485.&lt;BR /&gt;&lt;BR /&gt;RS485 is simply another 'electrical' interface for serial data. Logically, it is like RS232, in that it runs at a baud rate, and has a start-bit, seven, eight or nine data bits, an optional parity bit and one or two stop bits.&lt;BR /&gt;&lt;BR /&gt;Where it is different from RS232 is in the electrical levels of the signals and the physical characteristics of the wiring. You would hook your SCI pins up to a driver/receiver IC designed for RS485.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:09:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141275#M3253</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-06-29T14:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141276#M3254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Yea RS485 uses the SCI port. I learned about RS485 with my Dragon12. The schematic shows me how to control the direction bit, which RS232 does not use. And it uses a different driver chip than RS232 which takes the direction signal to control input/output.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 20:47:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141276#M3254</guid>
      <dc:creator>imajeff</dc:creator>
      <dc:date>2006-06-29T20:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141277#M3255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;using the rs485 interface with SCI&lt;BR /&gt;I have attempted to replicate the needed CTS/RTS hardware handshake protocol, as suggested earlier by asserting the PJ0 pin to create a clear to send signal.&lt;BR /&gt;My motorcontroller still remains unresponsive.&lt;BR /&gt;I know that I am transmitting something since the TX LED lights up when I send. However, I have observed the RX LED to flicker before and after my program starts. I have been unable to collect any data.&lt;BR /&gt;&lt;BR /&gt;Here is my control register setup and my "assert command".&lt;BR /&gt;&lt;BR /&gt; char *error = "1TE?\r\n";&lt;BR /&gt; &lt;BR /&gt; PTIJ = PTIJ | 0x01; //assert PJ0&lt;BR /&gt; puts2SCI1(error);&lt;BR /&gt; PTIJ = PTIJ &amp;amp; ~0x01; //de-assert PJ0&lt;BR /&gt; getsSCI1(data);&lt;BR /&gt; cmd2lcd(0x83); &lt;BR /&gt; puts2lcd(data); &lt;BR /&gt;&lt;BR /&gt;void init_SCI1(void){&lt;BR /&gt; SCI1BDH = 0x00;&lt;BR /&gt; SCI1BDL = 78; /* set baud rate to 19200 */&lt;BR /&gt; SCI1CR1 = 0x00; //8-N-1&lt;BR /&gt; SCI1CR2 = 0x0C;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void putc2SCI1(char xc){&lt;BR /&gt; while (!(SCI1SR1&amp;amp;TDRE));&lt;BR /&gt; SCI1DRL = xc;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void puts2SCI1(char *ptr){&lt;BR /&gt; while(*ptr) {&lt;BR /&gt; putc2SCI1(*ptr);&lt;BR /&gt; ptr++;&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;rdelljh&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 13:57:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141277#M3255</guid>
      <dc:creator>rdelljh</dc:creator>
      <dc:date>2006-06-30T13:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: I2C baud rate and slave address problem</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141278#M3256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, rdelljh:&lt;BR /&gt;&lt;BR /&gt;I think you may need to wait for "Transmission Complete" before de-asserting PJ0. As it looks now, you would be de-asserting PJ0 right after loading the last byte into the buffer, which means the second-to-last byte has just started shifting out.&lt;BR /&gt;&lt;BR /&gt;The motor controller will not receive the "\n", and will only receive the first bit or two of the "\r".&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jun 2006 15:15:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/I2C-baud-rate-and-slave-address-problem/m-p/141278#M3256</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-06-30T15:15:38Z</dc:date>
    </item>
  </channel>
</rss>

