<?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>8-bit MicrocontrollersのトピックRe: MC9S08PA4 SCI debugging problems</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246583#M19702</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Mac,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for all your help about the MC9S08PA4. Now we have another problem about I.MX 281. We write the bareboard program and want to dowload it into the SPI flash and boot from it. The problem is if we want to run our bareboard program in the SPI flash, what we need to do ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for all your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tel: 0510-8029 5234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anny Li&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;在 2013-05-30 21:37:21，bigmac &amp;lt;admin@community.freescale.com&amp;gt; 写道：&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;MC9S08PA4 SCI debugging problems&lt;/P&gt;&lt;P&gt;created by bigmac in 8-bit Microcontrollers - View the full discussion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The primary problem with your test project is that the main() function does not enter a continuous loop following initialisation, but exits the function.  For a MCU, the main() function must never exit.  There may also be secondary issues regarding the handling of the COP (watchdog) timer to prevent COP reset.  I might suggest that you use the project wizard to create a main() framework for each new project, where both these issues are taken into account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code demonstrates an alternative basic test project, where every character received by the SCI is immediately re-transmitted (echoed) back to the remote end.  I have not shown the code for the initialisation functions.  Additionally, I have defined the interrupt handler function using a "vector number", rather than including a vector table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Global variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;byte rx;&lt;/P&gt;&lt;P&gt;byte flag = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Function prototypes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void MCU_init( void);&lt;/P&gt;&lt;P&gt;void Init_SCI0( void);&lt;/P&gt;&lt;P&gt;void echo_char( void);&lt;/P&gt;&lt;P&gt;void SCI_sendchar( byte c);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  MCU_init();&lt;/P&gt;&lt;P&gt;  Init_SCI0();&lt;/P&gt;&lt;P&gt;  EnableInterrupts;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  for ( ; ; ) {      // Commence main loop&lt;/P&gt;&lt;P&gt;    __RESET_WATCHDOG();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    echo_char();     // Echo received character (if any)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  } // Loop always - do not exit main()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Echo received character&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void echo_char( void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  if (flag) {       // New character received&lt;/P&gt;&lt;P&gt;    flag = 0;&lt;/P&gt;&lt;P&gt;    sendchar( rx);  // Send character&lt;/P&gt;&lt;P&gt;  }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Send character to SCI0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void SCI_sendchar( byte c)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  while ((SCI0_S1 &amp;amp; 0x80) == 0);  // Wait for TDRE flag set&lt;/P&gt;&lt;P&gt;  SCI0_D = c;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// SCI0 Receive interrupt handler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__interrupt Vsci0rx&lt;/P&gt;&lt;P&gt;void isr_sci0rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  rx = SCI0_S1; // Part of clear flag process&lt;/P&gt;&lt;P&gt;  rx = SCI0_D;  // Fetch received character&lt;/P&gt;&lt;P&gt;  flag = 1;     // Flag new character available&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reply to this message by replying to this email -or- go to the message on Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Start a new discussion in 8-bit Microcontrollers by email or at Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 May 2013 08:42:47 GMT</pubDate>
    <dc:creator>annyli</dc:creator>
    <dc:date>2013-05-31T08:42:47Z</dc:date>
    <item>
      <title>MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246578#M19697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;when I debugging the MC9S08PA4 SCI, I can not write the SCI0_D registers when I want to send message. My configer is as following:&lt;/P&gt;&lt;P&gt;void Init_SCI0(void)&lt;BR /&gt;{&lt;BR /&gt; SYS_SOPT1_SCI0PS=1; //SCI0 RXD &amp;amp; TXD MAPPED ON PTA2 &amp;amp; PTA3&lt;BR /&gt; ADC_APCTL1_ADPC2=1; //disable the ADP&lt;BR /&gt; ADC_APCTL1_ADPC3=1; //disable the ADP&lt;BR /&gt; &lt;BR /&gt; SCI0_BDH=0b00000000;//set the baud rate&lt;BR /&gt; SCI0_BDL=0b00110100; //baud rate is 9600 b/s, internal clock 8MHz&lt;BR /&gt; SCI0_C1=0x00;//0x00:8bits&lt;BR /&gt; &lt;BR /&gt; SCI0_C2_TE=1; //TRANSMITTER ENABLE&lt;BR /&gt; SCI0_C2_TIE=1;//inable the interrupt&lt;BR /&gt; dummy=SCI0_S1;&lt;BR /&gt;&amp;nbsp; SCI0_D='a';&amp;nbsp; &lt;BR /&gt; }&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Who can help me? Pls...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 May 2013 03:17:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246578#M19697</guid>
      <dc:creator>annyli</dc:creator>
      <dc:date>2013-05-20T03:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246579#M19698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you have enabled transmit interrupts, you will need an interrupt handler.&amp;nbsp; If you do not have one, the MCU will most likely hang, eventually resulting in a COP timeout (unless the COP has been disabled).&amp;nbsp; Perhaps you do not need to use transmit interrupts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void SCI_sendchar( byte c)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; while ((SCI0_S1 &amp;amp; 0x80) == 0);&amp;nbsp; // Wait for TDRE flag set&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; SCI0_D = c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 May 2013 19:57:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246579#M19698</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-05-21T19:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246580#M19699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help. But now I have the new problems, when I use interrupt to receive a data, the problem can't enter into the ISR.&lt;/P&gt;&lt;P&gt;I have enabled the SCI0_RIE=1; Following is the details:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Receiver Interrupt Enable for RDRF&lt;/P&gt;&lt;P&gt;0 Hardware interrupts from RDRF disabled; use polling.&lt;/P&gt;&lt;P&gt;1 Hardware interrupt requested when RDRF flag is 1.&lt;/P&gt;&lt;P&gt;And after send the data the RDRF flag has changed to 1, but the ISR did not run. The ISR code is as following:&lt;/P&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;DisableInterrupts; /* enable interrupts */&lt;/P&gt;&lt;P&gt;MCU_init(); /* call Device Initialization */&lt;/P&gt;&lt;P&gt;Init_SCI0(); /* call Device Initialization */&lt;/P&gt;&lt;P&gt;EnableInterrupts;&lt;/P&gt;&lt;P&gt;while(!(SCI0_S1&amp;amp;0X80));&lt;/P&gt;&lt;P&gt;SCI0_D=0b00000011; //send the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (rx==0x03)&lt;/P&gt;&lt;P&gt;flag=1;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;flag=0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__interrupt void isrVsci0rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;dummy=SCI0_S1; // 清除s1标志位第一步&lt;/P&gt;&lt;P&gt;rx=SCI0_D;&lt;/P&gt;&lt;P&gt;//EnableInterrupts;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__interrupt void isrVsci0rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;dummy=SCI0_S1; // 清除s1标志位第一步&lt;/P&gt;&lt;P&gt;rx=SCI0_D;&lt;/P&gt;&lt;P&gt;//EnableInterrupts;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static void (* near const _vect[])(void) @0xFFB0 = { /* Interrupt vector table */&lt;/P&gt;&lt;P&gt;/*lint -restore Enable MISRA rule (1.1) checking. */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 39 Vnvm (at FFB0) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 38 VReserved38 (at FFB2) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 37 Vkbi0 (at FFB4) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 36 VReserved36 (at FFB6) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 35 Vrtc (at FFB8) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 34 VReserved34 (at FFBA) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 33 VReserved33 (at FFBC) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 32 VReserved32 (at FFBE) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 31 VReserved31 (at FFC0) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 30 VReserved30 (at FFC2) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 29 VReserved29 (at FFC4) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 28 VReserved28 (at FFC6) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 27 VReserved27 (at FFC8) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 26 VReserved26 (at FFCA) Unassigned */&lt;/P&gt;&lt;P&gt;isrVsci0tx, /* Int.no. 25 Vsci0tx (at FFCC) Used */&lt;/P&gt;&lt;P&gt;isrVsci0rx, /* Int.no. 24 Vsci0rx (at FFCE) Used */&lt;/P&gt;&lt;P&gt;isrVsci0err, /* Int.no. 23 Vsci0err (at FFD0) Used */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 22 Vadc (at FFD2) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 21 Vacmp (at FFD4) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 20 VReserved20 (at FFD6) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 19 VReserved19 (at FFD8) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 18 Vftm0ovf (at FFDA) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 17 Vftm0ch1 (at FFDC) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 16 Vftm0ch0 (at FFDE) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 15 Vftm1ovf (at FFE0) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 14 Vftm1ch1 (at FFE2) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 13 Vftm1ch0 (at FFE4) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 12 VReserved12 (at FFE6) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 11 VReserved11 (at FFE8) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 10 VReserved10 (at FFEA) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 9 VReserved9 (at FFEC) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 8 VReserved8 (at FFEE) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 7 VReserved7 (at FFF0) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 6 VReserved6 (at FFF2) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 5 VReserved5 (at FFF4) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 4 Vclk (at FFF6) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 3 Vlvw (at FFF8) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 2 Virq_wdog (at FFFA) Unassigned */&lt;/P&gt;&lt;P&gt;UNASSIGNED_ISR, /* Int.no. 1 Vswi (at FFFC) Unassigned */&lt;/P&gt;&lt;P&gt;_Startup /* Int.no. 0 Vreset (at FFFE) Reset vector */&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;在 2013-05-22 03:58:22，bigmac &amp;lt;admin@community.freescale.com&amp;gt; 写道：&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;MC9S08PA4 SCI debugging problems&lt;/P&gt;&lt;P&gt;created by bigmac in 8-bit Microcontrollers - View the full discussion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you have enabled transmit interrupts, you will need an interrupt handler.  If you do not have one, the MCU will most likely hang, eventually resulting in a COP timeout (unless the COP has been disabled).  Perhaps you do not need to use transmit interrupts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void SCI_sendchar( byte c)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  while ((SCI0_S1 &amp;amp; 0x80) == 0);  // Wait for TDRE flag set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SCI0_D = c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reply to this message by replying to this email -or- go to the message on Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Start a new discussion in 8-bit Microcontrollers by email or at Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 May 2013 08:23:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246580#M19699</guid>
      <dc:creator>annyli</dc:creator>
      <dc:date>2013-05-29T08:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246581#M19700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The primary problem with your test project is that the main() function does not enter a continuous loop following initialisation, but exits the function.&amp;nbsp; For a MCU, the main() function must &lt;SPAN style="text-decoration: underline;"&gt;never&lt;/SPAN&gt; exit.&amp;nbsp; There may also be secondary issues regarding the handling of the COP (watchdog) timer to prevent COP reset.&amp;nbsp; I might suggest that you use the project wizard to create a main() framework for each new project, where both these issues are taken into account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code demonstrates an alternative basic test project, where every character received by the SCI is immediately re-transmitted (echoed) back to the remote end.&amp;nbsp; I have not shown the code for the initialisation functions.&amp;nbsp; Additionally, I have defined the interrupt handler function using a "vector number", rather than including a vector table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Global variables:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;byte rx;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;byte flag = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//*****************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Function prototypes:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void MCU_init( void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void Init_SCI0( void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void echo_char( void);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void SCI_sendchar( byte c);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//*****************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void main(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; MCU_init();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Init_SCI0();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; EnableInterrupts;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; for ( ; ; ) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Commence main loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __RESET_WATCHDOG();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo_char();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Echo received character (if any)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; } // Loop always - do not exit main()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//*****************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Echo received character&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void echo_char( void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; if (flag) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // New character received&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flag = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sendchar( rx);&amp;nbsp; // Send character&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//*****************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Send character to SCI0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void SCI_sendchar( byte c)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; while ((SCI0_S1 &amp;amp; 0x80) == 0);&amp;nbsp; // Wait for TDRE flag set&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; SCI0_D = c;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//*****************************************************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// SCI0 Receive interrupt handler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;__interrupt Vsci0rx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void isr_sci0rx(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; rx = SCI0_S1; // Part of clear flag process&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; rx = SCI0_D;&amp;nbsp; // Fetch received character&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; flag = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Flag new character available&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 May 2013 13:35:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246581#M19700</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-05-30T13:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246582#M19701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mac,&lt;/P&gt;&lt;P&gt;Thank you very much for all your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2013 08:15:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246582#M19701</guid>
      <dc:creator>annyli</dc:creator>
      <dc:date>2013-05-31T08:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246583#M19702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Mac,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for all your help about the MC9S08PA4. Now we have another problem about I.MX 281. We write the bareboard program and want to dowload it into the SPI flash and boot from it. The problem is if we want to run our bareboard program in the SPI flash, what we need to do ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for all your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tel: 0510-8029 5234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anny Li&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;在 2013-05-30 21:37:21，bigmac &amp;lt;admin@community.freescale.com&amp;gt; 写道：&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;MC9S08PA4 SCI debugging problems&lt;/P&gt;&lt;P&gt;created by bigmac in 8-bit Microcontrollers - View the full discussion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The primary problem with your test project is that the main() function does not enter a continuous loop following initialisation, but exits the function.  For a MCU, the main() function must never exit.  There may also be secondary issues regarding the handling of the COP (watchdog) timer to prevent COP reset.  I might suggest that you use the project wizard to create a main() framework for each new project, where both these issues are taken into account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code demonstrates an alternative basic test project, where every character received by the SCI is immediately re-transmitted (echoed) back to the remote end.  I have not shown the code for the initialisation functions.  Additionally, I have defined the interrupt handler function using a "vector number", rather than including a vector table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Global variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;byte rx;&lt;/P&gt;&lt;P&gt;byte flag = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Function prototypes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void MCU_init( void);&lt;/P&gt;&lt;P&gt;void Init_SCI0( void);&lt;/P&gt;&lt;P&gt;void echo_char( void);&lt;/P&gt;&lt;P&gt;void SCI_sendchar( byte c);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  MCU_init();&lt;/P&gt;&lt;P&gt;  Init_SCI0();&lt;/P&gt;&lt;P&gt;  EnableInterrupts;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  for ( ; ; ) {      // Commence main loop&lt;/P&gt;&lt;P&gt;    __RESET_WATCHDOG();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    echo_char();     // Echo received character (if any)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  } // Loop always - do not exit main()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Echo received character&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void echo_char( void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  if (flag) {       // New character received&lt;/P&gt;&lt;P&gt;    flag = 0;&lt;/P&gt;&lt;P&gt;    sendchar( rx);  // Send character&lt;/P&gt;&lt;P&gt;  }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// Send character to SCI0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void SCI_sendchar( byte c)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  while ((SCI0_S1 &amp;amp; 0x80) == 0);  // Wait for TDRE flag set&lt;/P&gt;&lt;P&gt;  SCI0_D = c;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//*****************************************************************************&lt;/P&gt;&lt;P&gt;// SCI0 Receive interrupt handler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__interrupt Vsci0rx&lt;/P&gt;&lt;P&gt;void isr_sci0rx(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  rx = SCI0_S1; // Part of clear flag process&lt;/P&gt;&lt;P&gt;  rx = SCI0_D;  // Fetch received character&lt;/P&gt;&lt;P&gt;  flag = 1;     // Flag new character available&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reply to this message by replying to this email -or- go to the message on Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Start a new discussion in 8-bit Microcontrollers by email or at Freescale Community&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;P&gt;|&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2013 08:42:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246583#M19702</guid>
      <dc:creator>annyli</dc:creator>
      <dc:date>2013-05-31T08:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08PA4 SCI debugging problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246584#M19703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Anny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;anny li wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thank you for all your help about the MC9S08PA4. Now we have another problem about I.MX 281. We write the bareboard program and want to dowload it into the SPI flash and boot from it. The problem is if we want to run our bareboard program in the SPI flash, what we need to do ?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Unfortunately, I am not familar with the iMX product.&amp;nbsp; You may do better to post this question to the iMX forum, if you have not already done so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jun 2013 04:28:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08PA4-SCI-debugging-problems/m-p/246584#M19703</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-06-05T04:28:28Z</dc:date>
    </item>
  </channel>
</rss>

