<?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: I am interfacing a peripheral to UART0. When I try to write data to it for the first time it is not writing to the peripheral. in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291868#M9362</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chandra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible that your device is doing some kind of auto calibration for the baude rate. This is common in some UART devices.&lt;/P&gt;&lt;P&gt;Have you checked if the datasheet mentions this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would also recomend a interrupt approach. You can take a look of a source code that uses the itty driver. Take a look to this appnote and its source code:&lt;/P&gt;&lt;P&gt;&lt;A href="http://cache.freescale.com/files/32bit/doc/app_note/AN4022.pdf?fsrch=1&amp;amp;sr=3"&gt;http://cache.freescale.com/files/32bit/doc/app_note/AN4022.pdf?fsrch=1&amp;amp;sr=3&lt;/A&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I hope this helps you. Good luck with your project!&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Garabo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Dec 2013 19:36:57 GMT</pubDate>
    <dc:creator>Luis_Garabo</dc:creator>
    <dc:date>2013-12-04T19:36:57Z</dc:date>
    <item>
      <title>I am interfacing a peripheral to UART0. When I try to write data to it for the first time it is not writing to the peripheral.</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291867#M9361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using TWR-K21F120M board. Using MQX4.0. &lt;/P&gt;&lt;P&gt;I am interfacing a finger print scanner to UART0. I am unable to write data to it for the first time. But it takes data for the second time. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unsigned char buffer[] = {0x02, 0x61, 0x02, 0x21, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0xDD, 0x69, 0x1B, 0x03}; &lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char buffer1[100] = {0x00};&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint_8 count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint_32 Baudrate=9600;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; UARTA = fopen("ttya:",(char const*)(IO_SERIAL_RAW_IO|IO_SERIAL_TRANSLATION)); &lt;STRONG&gt;//opening the device &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; if(NULL==UARTA)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _task_block();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; if( MQX_OK !=_io_ioctl(UARTA,IO_IOCTL_SERIAL_SET_BAUD,&amp;amp;Baudrate)) //UART0 settings&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; _task_block();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while(TRUE)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = write(UARTA,buffer,sizeof(buffer)); //Writing data to UARTA,Even though the return value is positive, the data is not going to the peripheral connected to the UART0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 4; i++)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read(UARTA,buffer1,4); //&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 4; i++)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(" the buffer is %02X", buffer1[i]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody explain why this is happening.?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 09:04:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291867#M9361</guid>
      <dc:creator>chandrasekhar</dc:creator>
      <dc:date>2013-11-21T09:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: I am interfacing a peripheral to UART0. When I try to write data to it for the first time it is not writing to the peripheral.</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291868#M9362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chandra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible that your device is doing some kind of auto calibration for the baude rate. This is common in some UART devices.&lt;/P&gt;&lt;P&gt;Have you checked if the datasheet mentions this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would also recomend a interrupt approach. You can take a look of a source code that uses the itty driver. Take a look to this appnote and its source code:&lt;/P&gt;&lt;P&gt;&lt;A href="http://cache.freescale.com/files/32bit/doc/app_note/AN4022.pdf?fsrch=1&amp;amp;sr=3"&gt;http://cache.freescale.com/files/32bit/doc/app_note/AN4022.pdf?fsrch=1&amp;amp;sr=3&lt;/A&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;I hope this helps you. Good luck with your project!&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Garabo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 19:36:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291868#M9362</guid>
      <dc:creator>Luis_Garabo</dc:creator>
      <dc:date>2013-12-04T19:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: I am interfacing a peripheral to UART0. When I try to write data to it for the first time it is not writing to the peripheral.</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291869#M9363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Garabo,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;I thought the same way, but the peripheral datasheet doesn't say anything about the baudrate auto calibration. though we also worked with the MC9S08JM32 controller previously and we didnt face this issue, we also worked with K20 controller. I am facing issue with the K21. Currently we are opting for baremetal.&amp;nbsp; &lt;/P&gt;&lt;P&gt;If there is anything like auto &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;calibration on the controller side, how to manage that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;In the below code what are the settings/values that need to be changed. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; sbr = (uint16)((sysclk*1000)/(baud * 16));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Save off the current value of the UARTx_BDH except for the SBR field */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = UART_BDH_REG(uartch) &amp;amp; ~(UART_BDH_SBR(0x1F));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_BDH_REG(uartch) = temp |&amp;nbsp; UART_BDH_SBR(((sbr &amp;amp; 0x1F00) &amp;gt;&amp;gt; 8));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_BDL_REG(uartch) = (uint8)(sbr &amp;amp; UART_BDL_SBR_MASK);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Determine if a fractional divider is needed to get closer to the baud rate */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brfa = (((sysclk*32000)/(baud * 16)) - (sbr * 32));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Save off the current value of the UARTx_C4 register except for the BRFA field */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = UART_C4_REG(uartch) &amp;amp; ~(UART_C4_BRFA(0x1F));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_C4_REG(uartch) = temp |&amp;nbsp; UART_C4_BRFA(brfa);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Chandrasekhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 11:29:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/I-am-interfacing-a-peripheral-to-UART0-When-I-try-to-write-data/m-p/291869#M9363</guid>
      <dc:creator>chandrasekhar</dc:creator>
      <dc:date>2013-12-05T11:29:18Z</dc:date>
    </item>
  </channel>
</rss>

