<?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: MC9S08PA4 - UART example code over SCI in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1232232#M23281</link>
    <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;&amp;nbsp;​ Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, Thank you for opening the Ticket.&lt;/P&gt;&lt;P&gt;I just manage to run UART and I've uses the SCI0_D register as PutChar() func.&lt;/P&gt;&lt;P&gt;the problem that I facing is while I trying to send a few Chars using the following code:&lt;/P&gt;&lt;P&gt;while (SCI0_S1_TDRE == 1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = (unsigned char)tmpvalue[0];&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buf_tx = (unsigned char)tmpvalue[1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = '\n';&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = '\r';&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;but in the terminal, I did not get all the prints, so I think there is a flag that is a purpose to tell the buffer is ready to TX... (maybe adding a small delay could fix it).&lt;/P&gt;&lt;P&gt;please advise the correct way to works with SCI/UART to overcome this issues, Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Shai&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2021 18:20:39 GMT</pubDate>
    <dc:creator>shai_b</dc:creator>
    <dc:date>2021-02-17T18:20:39Z</dc:date>
    <item>
      <title>MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1223984#M23261</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;&lt;P&gt;My Customer is working with MC9S08PA4 and he wishes to add&amp;nbsp;UART communication and plans to use only transmitting ASCII character (TX ch.), for ex, putchar() or printf() functions, but he did not found any useful&amp;nbsp;tutorials/documentation on how to accomplish.&lt;/P&gt;&lt;P&gt;Could you please provide a useful example code for MC9S08PA4 (16Mhz CLK) on how to use UART ch to use "printf()" or "putchar()"?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am waiting for your kind response, Thanks in advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shai&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 10:08:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1223984#M23261</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-01T10:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1225034#M23263</link>
      <description>&lt;P&gt;HI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check the following thread&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-sample/m-p/252881" target="_blank"&gt;https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-sample/m-p/252881&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also I do not recommend to use printf on a S08 device, it use a lot of memory&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Vicente Gomez&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 00:09:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1225034#M23263</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2021-02-03T00:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1226583#M23264</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;&amp;nbsp;hello,&lt;/P&gt;&lt;P&gt;Thanks for your help, I've tried adding the SCI driver into my code but I did not get any output (I even check with the scope on the lines and did not see any signal).&lt;/P&gt;&lt;P&gt;Could you please review my code changed and see if I did something wrong?&lt;/P&gt;&lt;P&gt;I've added the uart.c and uart.h into my project&amp;nbsp;&lt;/P&gt;&lt;P&gt;in main.c&lt;/P&gt;&lt;P&gt;#include "uart.h"&amp;nbsp; &amp;nbsp;//adding the UART.H&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unsigned char uart_buf; //global uart buffer&lt;/P&gt;&lt;P&gt;void main()&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;PORT_PTBOE_PTBOE1 = 1;&amp;nbsp; PORT_PTBIE_PTBIE0 = 1;&amp;nbsp;/* config relevant pins as TX(output) and RX(input)&amp;nbsp; */&amp;nbsp;&lt;BR /&gt;Init_SCI0(BUS_CLK_HZ);&amp;nbsp; &amp;nbsp; //init SCI0 for uart tx/rx&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;while(1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;(void) SCI0_S1; // read SCIS1 register for clear RDRF flag&lt;BR /&gt;uart_buf = 'A';&lt;BR /&gt;SCI0_D = uart_buf; // send via uart "A" char&lt;BR /&gt;&lt;BR /&gt;wait_sci_tx_empty();&lt;BR /&gt;&lt;BR /&gt;(void) SCI0_S1; // read SCIS1 register for clear RDRF flag&lt;BR /&gt;uart_buf = '\n';&lt;BR /&gt;SCI0_D = uart_buf; // send via uart "\n" char&lt;BR /&gt;&lt;BR /&gt;wait_sci_tx_empty();&lt;BR /&gt;&lt;BR /&gt;(void) SCI0_S1; // read SCIS1 register for clear RDRF flag&lt;BR /&gt;uart_buf = '\0';&lt;BR /&gt;SCI0_D = uart_buf; // send via uart "\0" char&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waiting for your kind responses, Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shai&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 18:59:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1226583#M23264</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-04T18:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1228894#M23272</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is any update? Could you please review my code?&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;KR,&lt;/P&gt;&lt;P&gt;Shai&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 16:40:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1228894#M23272</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-09T16:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1229010#M23273</link>
      <description>&lt;P&gt;I am not seeing where are you setting the baud rate?&lt;/P&gt;
&lt;P&gt;can you send me the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Init_SCI0(BUS_CLK_HZ); function?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;normally you need to set something like this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SCI2_BD |= 52; //set baud rate 9600 (8Mhz/(16 x 52))&amp;nbsp; // in your case SCI0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;this is a simple sample code&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;void SCI2RX_ISR(void);&lt;/P&gt;
&lt;P&gt;unsigned char u8receiver, flag,chema = 0;&lt;BR /&gt;void main(void) {&lt;BR /&gt;EnableInterrupts;&lt;BR /&gt;/* include your code here */&lt;BR /&gt;/* WDOG_CNT: CNT=0xC520 */&lt;BR /&gt;WDOG_CNT = 0xC520; /* First part of the WDG unlock sequence */ &lt;BR /&gt;/* WDOG_CNT: CNT=0xD928 */&lt;BR /&gt;WDOG_CNT = 0xD928; /* Second part of the WDG unlock sequence */ &lt;BR /&gt;/* WDOG_TOVAL: TOVAL=4 */&lt;BR /&gt;WDOG_TOVAL = 0x04; &lt;BR /&gt;/* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=1 */&lt;BR /&gt;WDOG_CS2 = 0x01; &lt;BR /&gt;/* WDOG_CS1: EN=0,INT=0,UPDATE=0,TST=0,DBG=0,WAIT=0,STOP=0 */&lt;BR /&gt;WDOG_CS1 = 0x00; /* Disable watchdog */ &lt;BR /&gt;/* System clock initialization */&lt;BR /&gt;/*lint -save -e923 Disable MISRA rule (11.3) checking. */&lt;BR /&gt;if (*(unsigned char*far)0xFF6FU != 0xFFU) { /* Test if the device trim value is stored on the specified address */&lt;BR /&gt;ICS_C3 = *(unsigned char*far)0xFF6FU; /* Initialize ICS_C3 register from a non volatile memory */&lt;BR /&gt;ICS_C4 = (unsigned char)((*(unsigned char*far)0xFF6EU) &amp;amp; (unsigned char)0x01U); /* Initialize ICS_C4 register from a non volatile memory */&lt;BR /&gt;}&lt;BR /&gt;/*lint -restore Enable MISRA rule (11.3) checking. */&lt;BR /&gt;/* ICS_C1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */&lt;BR /&gt;ICS_C1 = 0x06U; /* Initialization of the ICS control register 1 */&lt;BR /&gt;/* ICS_C2: BDIV=1,LP=0 */&lt;BR /&gt;ICS_C2 = 0x20U; /* Initialization of the ICS control register 2 */&lt;BR /&gt;/* ICS_C4: LOLIE=0,CME=0 */&lt;BR /&gt;ICS_C4 &amp;amp;= (unsigned char)~(unsigned char)0xA0U;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SCI2_C1 = 0x00; /* Reset flags */&lt;BR /&gt;SCI2_C3 = 0x00; /* Configure the SCI */ &lt;BR /&gt;SCI2_C2 = 0x00; /* Disable error interrupts */ &lt;BR /&gt;SCI2_S2 = 0x00; /* Disable all interrupts */ &lt;BR /&gt;SCI2_BD |= 52; //set baud rate 9600 (8Mhz/(16 x 52)) &lt;BR /&gt;SCI2_C1 |= 0x00;&lt;BR /&gt;SCI2_C2 |= (SCI2_C2_TE_MASK | SCI2_C2_RE_MASK);//| SCI2_C2_RIE_MASK); /* Enable transmitter, Enable receiver, Enable receiver interrupt */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for(;;) &lt;BR /&gt;{&lt;BR /&gt;// __RESET_WATCHDOG(); /* feeds the dog */&lt;BR /&gt;while (SCI2_S1_TDRE == 1)&lt;BR /&gt;{&lt;BR /&gt;SCI2_D =('a');&lt;BR /&gt;}&lt;BR /&gt;} /* loop forever */&lt;BR /&gt;/* please make sure that you never leave main */&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;/***************************************************************************************/&lt;/P&gt;
&lt;P&gt;interrupt VectorNumber_Vsci2rx void SCI2RX_ISR(void) &lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;(void) SCI2_S1; // read SCIS1 register for clear RDRF flag &lt;BR /&gt;u8receiver = SCI2_D;&lt;BR /&gt;//SCI2_D = 1+u8receiver;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;/***************************************************************************************/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 21:42:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1229010#M23273</guid>
      <dc:creator>vicentegomez</dc:creator>
      <dc:date>2021-02-09T21:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1229028#M23275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for missing the init_SCI0 functions but it is part of the 'uart.c' libs and the&amp;nbsp;BUS_CLK_HZ defines as&amp;nbsp;16000000L (16Mhz).&lt;/P&gt;&lt;P&gt;you can find below&amp;nbsp;Init_SCI0 function&lt;/P&gt;&lt;P&gt;void Init_SCI0(dword busCLKHz)&lt;BR /&gt;{&lt;BR /&gt;SCG_C3 |= SCG_C3_SCI0_MASK; //enable clock gate for SCI0&lt;BR /&gt;&lt;BR /&gt;SCI0_BD = 104; //9600 = 16MHz/16/104&lt;BR /&gt;&lt;BR /&gt;SCI0_C1 = 0; // 8bit mode, 1 stop bit, no parity&lt;BR /&gt;SCI0_C2 = 0x0C; // enable TX , enable RX&lt;BR /&gt;}//end Init_SCI0_&lt;/P&gt;&lt;P&gt;For some reason I do not see any signal on the TX line, I am afraid I made a mistake while configuring the pins.&lt;BR /&gt;Could we take the rest of the support through emails because I do not want to reveal/share the full code in public?&lt;/P&gt;&lt;P&gt;Please advise back, Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:22:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1229028#M23275</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-09T22:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1232232#M23281</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;&amp;nbsp;​ Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, Thank you for opening the Ticket.&lt;/P&gt;&lt;P&gt;I just manage to run UART and I've uses the SCI0_D register as PutChar() func.&lt;/P&gt;&lt;P&gt;the problem that I facing is while I trying to send a few Chars using the following code:&lt;/P&gt;&lt;P&gt;while (SCI0_S1_TDRE == 1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = (unsigned char)tmpvalue[0];&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buf_tx = (unsigned char)tmpvalue[1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = '\n';&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;&amp;nbsp;(void) SCI0_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;buf_tx = '\r';&lt;/P&gt;&lt;P&gt;&amp;nbsp;SCI0_D = buf_tx;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;but in the terminal, I did not get all the prints, so I think there is a flag that is a purpose to tell the buffer is ready to TX... (maybe adding a small delay could fix it).&lt;/P&gt;&lt;P&gt;please advise the correct way to works with SCI/UART to overcome this issues, Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Shai&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 18:20:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1232232#M23281</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-17T18:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 - UART example code over SCI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1232881#M23284</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/35421"&gt;@vicentegomez&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I just found my solution, I've used "&lt;SPAN&gt;wait_sci_tx_empty();" -&amp;gt; to wait till SCI_TX buffer is ready.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and everything works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your time and effort.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KR,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Shai&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 13:44:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-UART-example-code-over-SCI/m-p/1232881#M23284</guid>
      <dc:creator>shai_b</dc:creator>
      <dc:date>2021-02-18T13:44:33Z</dc:date>
    </item>
  </channel>
</rss>

