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