<?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 How do I extract the ASCII characters from a stream coming from an external chip using SCI Rx (PTB0) and put them in the data buffer? in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-do-I-extract-the-ASCII-characters-from-a-stream-coming-from/m-p/597388#M22159</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Our MCU is MC9S08QG8CFFE. The data sheet is at&amp;nbsp;&lt;A class="link-titled" href="http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf" title="http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf"&gt;http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are using CodeWarrior I.D.E v 5.9.0.&lt;/P&gt;&lt;P&gt;We are unable to get the ASCII characters into the data buffer.&lt;/P&gt;&lt;P&gt;Our code is:&lt;/P&gt;&lt;P&gt;/******************************************************************************&lt;BR /&gt;* Copyright (C) 2005 Freescale Semiconductor, Inc.&lt;BR /&gt;* All Rights Reserved&lt;BR /&gt;*&lt;BR /&gt;* Filename: DEMO9S08QG8_Test.c&lt;BR /&gt;* Author: r1aald&lt;BR /&gt;* Revision: 1.0&lt;BR /&gt;*&lt;BR /&gt;* Description: This is the test code that will reside in the QG8 demo&lt;BR /&gt;* to provide an out of the box experience. This simple code&lt;BR /&gt;* blinks LED2 and toggles LED1 when SW1 is pressed.&lt;BR /&gt;*&lt;BR /&gt;* Notes: Also serves as an example for the 9S08QG8 demo board.&lt;BR /&gt;* Created using CodeWarrior 5.0 for HC(S)08.&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* include peripheral declarations */&lt;BR /&gt;#include "demo9S08QG8.h" /*include demo board declarations */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void InitPorts() &lt;BR /&gt;{&lt;BR /&gt; // Enable pull-ups on all input pins&lt;BR /&gt; //PTAPE = 0xFF;&lt;BR /&gt; //PTBPE = 0xFF;&lt;BR /&gt; &lt;BR /&gt; PTAD = 0b00010000;&lt;BR /&gt; PTBD = 0b00001011;&lt;BR /&gt; PTADD = 0b11011111;&lt;BR /&gt; PTBDD = 0b11111010;&lt;BR /&gt; &lt;BR /&gt; SCIBDH = 0b00000000;&lt;BR /&gt; SCIBDL = 0x33;&lt;BR /&gt; SCIC1 = 0b00000000;&lt;BR /&gt; SCIC2 = 0b00101100;&lt;BR /&gt; //SCIS1 = 0b00000000;&lt;BR /&gt; SCIS2 = 0b00000000;&lt;BR /&gt; SCIC3 = 0b00000000;&lt;BR /&gt; SCID = 0b00000000;&lt;BR /&gt; &lt;BR /&gt;} //end InitPorts&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt;char RecChar() &lt;BR /&gt;{&lt;BR /&gt; byte rec_char;&lt;/P&gt;&lt;P&gt;if (SCIS1_RDRF) // 1st half of RDRF clear procedure&lt;BR /&gt; rec_char = SCID; // 2nd half of RDRF clear procedure&lt;BR /&gt; &lt;BR /&gt; SCIC2_RE = 1; // enable Rx&lt;BR /&gt; &lt;BR /&gt; while(!SCIS1_RDRF)&lt;BR /&gt; {&lt;BR /&gt; __RESET_WATCHDOG();&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; rec_char = SCID; // get recieved character&lt;BR /&gt; //SendChar(rec_char); // echo received character&lt;BR /&gt; &lt;BR /&gt; return SCID;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt;void main(void) &lt;BR /&gt;{&lt;BR /&gt; byte rec_char;&lt;/P&gt;&lt;P&gt;DisableInterrupts;&lt;BR /&gt; &lt;BR /&gt; asm&lt;BR /&gt; {&lt;BR /&gt; rsp&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; InitPorts();&lt;BR /&gt; SOPT1 = 0b11100011; // b7 COP enabled, long timeout, stop mode enabled pta4 is output&lt;BR /&gt; &lt;BR /&gt; //***&lt;BR /&gt; // I think something needs to be cleared before data will be sent&lt;BR /&gt; // not sure what though&lt;BR /&gt; //***&lt;BR /&gt; if (SCIS1_RDRF) // 1st half of RDRF clear procedure&lt;BR /&gt; {&lt;BR /&gt; rec_char = SCID; // 2nd half of RDRF clear procedure&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; SCIC2_RE = 1; // enable Rx&lt;BR /&gt; SCIC2_ILIE = 1; // enable receiver interrupt&lt;BR /&gt; &lt;BR /&gt; EnableInterrupts; /* enable interrupts */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt; //***&lt;BR /&gt; // this is all stuff for the LED demo I'm leaving in here&lt;BR /&gt; //***&lt;BR /&gt;// ICSC2_BDIV = 3;&lt;BR /&gt;// LED1 =0;&lt;BR /&gt;// LED2 =0; /* Port B7 is connected to LED 2 */&lt;BR /&gt; &lt;BR /&gt; //PTBDD_PTBDD7 = 1; /* Set PTB7 as an output */&lt;BR /&gt; //PTBDD_PTBDD6 = 1; &lt;BR /&gt; &lt;BR /&gt; /** mtim_setup */&lt;BR /&gt; //MTIMCLK_PS = 8;&lt;BR /&gt; //MTIMCLK_CLKS = 0;&lt;BR /&gt; //MTIMMOD = 112;&lt;BR /&gt; &lt;BR /&gt; //MTIMMOD = 0; /* modulo = 50 */&lt;BR /&gt; //MTIMSC = 0x60; /* reset and start MTIM, enable ints */&lt;BR /&gt; &lt;BR /&gt; /** KBI Set Up foe SW1 */&lt;BR /&gt; //KBIPE_KBIPE2 =1; /* Enable Keyboard Pin */ &lt;BR /&gt; //KBISC_KBIE = 1; /* Enable Keyboard Interrupts */&lt;BR /&gt; //KBISC_KBACK = 1; /* Clear Pending Keyboard Interrupts */&lt;BR /&gt; //PTAPE_PTAPE2 = 1; /* Enable Pullup for Keyboard pin */&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; for(;;) &lt;BR /&gt; {&lt;BR /&gt; __RESET_WATCHDOG(); /* feeds the dog */&lt;BR /&gt; } /* loop forever */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/** KBI ISR */&lt;/P&gt;&lt;P&gt;//interrupt 18 void KBI_ISR(void) &lt;BR /&gt;//{&lt;BR /&gt;// KBISC_KBACK = 1; /* Clear Pending Keyboard Interrupts */&lt;BR /&gt;// LED1 = ~LED1; /* toggle Port */&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/** MTIM_ISR - ISR that accompanies the MTIM PWM routine. */&lt;BR /&gt;//interrupt 12 void MTIM_ISR(void) {&lt;BR /&gt;// MTIMSC_TOF=0; /* clear TOF */&lt;BR /&gt;// LED2 = ~LED2; /* toggle Port */&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;interrupt VectorNumber_Vscirx void VSCIRX_ISR(void)&lt;BR /&gt;{&lt;BR /&gt; //***&lt;BR /&gt; // I'm not really doing anything here... I just needed a place to put a breakpoint&lt;BR /&gt; // to see if it ever enters this interrupt function&lt;BR /&gt; //***&lt;BR /&gt; char input; &lt;BR /&gt; RecChar();&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 Mar 2017 14:07:05 GMT</pubDate>
    <dc:creator>brandondoucette</dc:creator>
    <dc:date>2017-03-18T14:07:05Z</dc:date>
    <item>
      <title>How do I extract the ASCII characters from a stream coming from an external chip using SCI Rx (PTB0) and put them in the data buffer?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-do-I-extract-the-ASCII-characters-from-a-stream-coming-from/m-p/597388#M22159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Our MCU is MC9S08QG8CFFE. The data sheet is at&amp;nbsp;&lt;A class="link-titled" href="http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf" title="http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf"&gt;http://www.nxp.com/assets/documents/data/en/data-sheets/MC9S08QG8.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are using CodeWarrior I.D.E v 5.9.0.&lt;/P&gt;&lt;P&gt;We are unable to get the ASCII characters into the data buffer.&lt;/P&gt;&lt;P&gt;Our code is:&lt;/P&gt;&lt;P&gt;/******************************************************************************&lt;BR /&gt;* Copyright (C) 2005 Freescale Semiconductor, Inc.&lt;BR /&gt;* All Rights Reserved&lt;BR /&gt;*&lt;BR /&gt;* Filename: DEMO9S08QG8_Test.c&lt;BR /&gt;* Author: r1aald&lt;BR /&gt;* Revision: 1.0&lt;BR /&gt;*&lt;BR /&gt;* Description: This is the test code that will reside in the QG8 demo&lt;BR /&gt;* to provide an out of the box experience. This simple code&lt;BR /&gt;* blinks LED2 and toggles LED1 when SW1 is pressed.&lt;BR /&gt;*&lt;BR /&gt;* Notes: Also serves as an example for the 9S08QG8 demo board.&lt;BR /&gt;* Created using CodeWarrior 5.0 for HC(S)08.&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;BR /&gt;#include "derivative.h" /* include peripheral declarations */&lt;BR /&gt;#include "demo9S08QG8.h" /*include demo board declarations */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void InitPorts() &lt;BR /&gt;{&lt;BR /&gt; // Enable pull-ups on all input pins&lt;BR /&gt; //PTAPE = 0xFF;&lt;BR /&gt; //PTBPE = 0xFF;&lt;BR /&gt; &lt;BR /&gt; PTAD = 0b00010000;&lt;BR /&gt; PTBD = 0b00001011;&lt;BR /&gt; PTADD = 0b11011111;&lt;BR /&gt; PTBDD = 0b11111010;&lt;BR /&gt; &lt;BR /&gt; SCIBDH = 0b00000000;&lt;BR /&gt; SCIBDL = 0x33;&lt;BR /&gt; SCIC1 = 0b00000000;&lt;BR /&gt; SCIC2 = 0b00101100;&lt;BR /&gt; //SCIS1 = 0b00000000;&lt;BR /&gt; SCIS2 = 0b00000000;&lt;BR /&gt; SCIC3 = 0b00000000;&lt;BR /&gt; SCID = 0b00000000;&lt;BR /&gt; &lt;BR /&gt;} //end InitPorts&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt;char RecChar() &lt;BR /&gt;{&lt;BR /&gt; byte rec_char;&lt;/P&gt;&lt;P&gt;if (SCIS1_RDRF) // 1st half of RDRF clear procedure&lt;BR /&gt; rec_char = SCID; // 2nd half of RDRF clear procedure&lt;BR /&gt; &lt;BR /&gt; SCIC2_RE = 1; // enable Rx&lt;BR /&gt; &lt;BR /&gt; while(!SCIS1_RDRF)&lt;BR /&gt; {&lt;BR /&gt; __RESET_WATCHDOG();&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; rec_char = SCID; // get recieved character&lt;BR /&gt; //SendChar(rec_char); // echo received character&lt;BR /&gt; &lt;BR /&gt; return SCID;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt;void main(void) &lt;BR /&gt;{&lt;BR /&gt; byte rec_char;&lt;/P&gt;&lt;P&gt;DisableInterrupts;&lt;BR /&gt; &lt;BR /&gt; asm&lt;BR /&gt; {&lt;BR /&gt; rsp&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; InitPorts();&lt;BR /&gt; SOPT1 = 0b11100011; // b7 COP enabled, long timeout, stop mode enabled pta4 is output&lt;BR /&gt; &lt;BR /&gt; //***&lt;BR /&gt; // I think something needs to be cleared before data will be sent&lt;BR /&gt; // not sure what though&lt;BR /&gt; //***&lt;BR /&gt; if (SCIS1_RDRF) // 1st half of RDRF clear procedure&lt;BR /&gt; {&lt;BR /&gt; rec_char = SCID; // 2nd half of RDRF clear procedure&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; SCIC2_RE = 1; // enable Rx&lt;BR /&gt; SCIC2_ILIE = 1; // enable receiver interrupt&lt;BR /&gt; &lt;BR /&gt; EnableInterrupts; /* enable interrupts */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt; //***&lt;BR /&gt; // this is all stuff for the LED demo I'm leaving in here&lt;BR /&gt; //***&lt;BR /&gt;// ICSC2_BDIV = 3;&lt;BR /&gt;// LED1 =0;&lt;BR /&gt;// LED2 =0; /* Port B7 is connected to LED 2 */&lt;BR /&gt; &lt;BR /&gt; //PTBDD_PTBDD7 = 1; /* Set PTB7 as an output */&lt;BR /&gt; //PTBDD_PTBDD6 = 1; &lt;BR /&gt; &lt;BR /&gt; /** mtim_setup */&lt;BR /&gt; //MTIMCLK_PS = 8;&lt;BR /&gt; //MTIMCLK_CLKS = 0;&lt;BR /&gt; //MTIMMOD = 112;&lt;BR /&gt; &lt;BR /&gt; //MTIMMOD = 0; /* modulo = 50 */&lt;BR /&gt; //MTIMSC = 0x60; /* reset and start MTIM, enable ints */&lt;BR /&gt; &lt;BR /&gt; /** KBI Set Up foe SW1 */&lt;BR /&gt; //KBIPE_KBIPE2 =1; /* Enable Keyboard Pin */ &lt;BR /&gt; //KBISC_KBIE = 1; /* Enable Keyboard Interrupts */&lt;BR /&gt; //KBISC_KBACK = 1; /* Clear Pending Keyboard Interrupts */&lt;BR /&gt; //PTAPE_PTAPE2 = 1; /* Enable Pullup for Keyboard pin */&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; for(;;) &lt;BR /&gt; {&lt;BR /&gt; __RESET_WATCHDOG(); /* feeds the dog */&lt;BR /&gt; } /* loop forever */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/** KBI ISR */&lt;/P&gt;&lt;P&gt;//interrupt 18 void KBI_ISR(void) &lt;BR /&gt;//{&lt;BR /&gt;// KBISC_KBACK = 1; /* Clear Pending Keyboard Interrupts */&lt;BR /&gt;// LED1 = ~LED1; /* toggle Port */&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/** MTIM_ISR - ISR that accompanies the MTIM PWM routine. */&lt;BR /&gt;//interrupt 12 void MTIM_ISR(void) {&lt;BR /&gt;// MTIMSC_TOF=0; /* clear TOF */&lt;BR /&gt;// LED2 = ~LED2; /* toggle Port */&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;interrupt VectorNumber_Vscirx void VSCIRX_ISR(void)&lt;BR /&gt;{&lt;BR /&gt; //***&lt;BR /&gt; // I'm not really doing anything here... I just needed a place to put a breakpoint&lt;BR /&gt; // to see if it ever enters this interrupt function&lt;BR /&gt; //***&lt;BR /&gt; char input; &lt;BR /&gt; RecChar();&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Mar 2017 14:07:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-do-I-extract-the-ASCII-characters-from-a-stream-coming-from/m-p/597388#M22159</guid>
      <dc:creator>brandondoucette</dc:creator>
      <dc:date>2017-03-18T14:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract the ASCII characters from a stream coming from an external chip using SCI Rx (PTB0) and put them in the data buffer?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/How-do-I-extract-the-ASCII-characters-from-a-stream-coming-from/m-p/597389#M22160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;//**************** SCI1 receiver interrupt **********************************&lt;BR /&gt;__interrupt void isrVsci1rx(void){ //SCI&lt;BR /&gt; while(!SCI1S1_RDRF);&lt;BR /&gt; sci_rx_buffer[sci_i]=SCI1D;&lt;BR /&gt; SCI1S2_RXEDGIF=0x1;&lt;BR /&gt; if((sci_i&amp;gt;0) &amp;amp;&amp;amp; (sci_rx_buffer[sci_i]==0x00)){&lt;BR /&gt; buildCommandQueue();&lt;BR /&gt; sci_i=0;&lt;BR /&gt; memset(sci_rx_buffer,0,SCI_RX_BUFFLENGTH);&lt;BR /&gt; executeCommandQueue(); &lt;BR /&gt; }&lt;BR /&gt; else sci_i++;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/***************************************************************************&lt;BR /&gt;**************** Initialize the SCIs ***************************************&lt;BR /&gt;***************************************************************************/&lt;BR /&gt;void initSci(void){&lt;BR /&gt; SCI1BDL = 0x34; //19200 baud @ 16MHz BusClk&lt;BR /&gt; SCI1BDH = 0x00;&lt;BR /&gt; SCI1C1 = 0x00;&lt;BR /&gt; SCI1C2 = 0x2C;&lt;BR /&gt; SCI1C3 = 0x00;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe that helps...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2017 10:46:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/How-do-I-extract-the-ASCII-characters-from-a-stream-coming-from/m-p/597389#M22160</guid>
      <dc:creator>Bert2</dc:creator>
      <dc:date>2017-03-23T10:46:25Z</dc:date>
    </item>
  </channel>
</rss>

