Chris Reinink

SCI and Codewarrior Debug - HCS08Q8

Discussion created by Chris Reinink on Dec 6, 2007
Latest reply on Dec 10, 2007 by Chris Reinink
Hi,
 
I'm new to programming and i'm slowly working through building up a development system of my own.  I'm using the HCS08Q8 on HW i developed myself along with an LCD display.  I'm having an issue where when i run the program within the Codewarrior Debugger it behaves flawlessly (i.e. when using hyperterminal i can send characters to the uP via the RxD pin, the code then sends the character onto the LCD and its displayed as expected).  However when i run the code without the Codewarrior Debugger (and after a reset) only SOME characters are displayed correctly, where others are not??  This problem is consistant, i.e. its always the same characters which are effected.  I've monitored the RxD pin with a CRO and the bit stream of the "effected characters" are identical btw running the system under Codewarrior Debugger and out of a reset, so i know at least the character is being received at the pin correctly.   
 
If i change the line below  " LCDPrint(&SCID,1);"  to, for example,     LCDPrint("8",1); it prints 8 perfectly every time under both running conditions.  However if "8" is received by SCID over the SCI it prints "x" (It definately receives "8" at the RxD pin, CRO verified).  I've read in other posts that the SPI block has exhibited similar "quirkyness" but going through those posts and attempting to applying relevant fixes to the SCI block have not yielded any joy.
 
Any ideas?
Thanks.
 
 
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "gentypes.h"
#include "portsDef.h"
/**********************************************************************************************************/
/*      Function Pre Processors                                                                           */
/**********************************************************************************************************/

void delay(uint16 delayit);
uint8 CharToPrint=0;
uint8 temp; /*dummy storage variable*/
uint8 temp2;
/**********************************************************************************************************/
/*      Main Routine                                                                                     */
/**********************************************************************************************************/
void main(void) {
SOPT1 = 0x52;   /*Disable watchdog. disable STOP mode. Disable /RESET pin function*/
BaudRateH = 0x00;
BaudRateL = 0xD0; /*set baud rate to 1200bps: Baud Rate = BusClk/(16 x BaudRateH|BaudRateL) */
SCIC1 = 0x00;  /*TxD/RxD on different lines, normal mode, no parity*/
SCIC2 = 0x2C;  /*TxD int disabled, RxD int enabled, TxD/RxD on. Normal TxD/RxD*/
SCIC3 = 0x00;
PTADD = 0x0F;   /*PTA0-PTA3 output*/
PTBDD |= 0x08;  /*LED Display*/
EnableInterrupts; /* enable interrupts */
  initialiseLCD();
  cursorAddress(0x00);
 
  for(;:smileywink: {
 
  while (CharToPrint){
    LCDPrint(&SCID,1);
    CharToPrint=0;
   
  } /*end while */
  } /* end for loop forever */
  /* please make sure that you never leave main */
}
/**********************************************************************************************************/
/*      Delay Routine                                                                                     */
/**********************************************************************************************************/
void delay(uint16 delayit) {
 
  uint16 i;
  i=0;
    for (i=0;i<delayit;i++){ /*delayit value based on 4Mhz clock and this instruction 25clk cycles per run*/
    }
}

/**********************************************************************************************************/
/*      Interrupt Routines                                                                                */
/**********************************************************************************************************/

void interrupt 15 ReceiveBufferFull(void){
  if (ReceiverFull()==1){  /* 2 step process in order to clear RDRF flag i.e. this is always true*/
    temp=SCID;
  } 
  CharToPrint = 1;
}
 
Added p/n to subject.


Message Edited by NLFSJ on 2007-12-09 06:29 PM

Outcomes