Cristian Mihai Serban

HCS08LL64 on Tower Kit SCI problem receiving above 4800 baud rate

Discussion created by Cristian Mihai Serban on Feb 13, 2011
Latest reply on Feb 16, 2011 by Cristian Mihai Serban

Hi

I'm trying to communicate with the S08LL64 MCU from my TWR-S08LL64-KIT through SCI from the PC.

I'm using a USB to RS-232 convertor and Putty on the PC.

SCI is in 2 wire mode:Rx and Tx

Same results when using interupts or using pooling.

I have no problem transmitting from the development board to the PC at any baud rates.

The problem appears when transmitting from the PC to the board. I can't use baud rates higher than 4800 because i receive junk characters and board signals Frame Errors.

At a baud rate of 4800 works almost perfectly. I'm initializing the board with help from Proccesor Expert.

Here is the generated code for a baud rate of 9600:

Cpu:

 

/** ###################################################################**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.**     Filename  : Cpu.C**     Project   : T1**     Processor : MC9S08LL64C_LQFP80**     Component : MC9S08LL64_80**     Version   : Component 01.006, Driver 01.35, CPU db: 3.00.023**     Datasheet : MC9S08LL64RM Rev. 4 07/2009**     Compiler  : CodeWarrior HCS08 C Compiler**     Date/Time : 12.02.2011, 20:27**     Abstract  :**         This bean "MC9S08LL64_80" contains initialization of the**         CPU and provides basic methods and events for CPU core**         settings.**     Settings  :****     Contents  :**         EnableInt  - void Cpu_EnableInt(void);**         DisableInt - void Cpu_DisableInt(void);****     Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.**     **     http      : www.freescale.com**     mail      : support@freescale.com** ###################################################################*//* MODULE Cpu. */#pragma MESSAGE DISABLE C4002 /* WARNING C4002: Result not used is ignored */#include "AS1.h"#include "PE_Types.h"#include "PE_Error.h"#include "PE_Const.h"#include "IO_Map.h"#include "Events.h"#include "Cpu.h"/* Global variables */volatile byte CCR_reg;                 /* Current CCR register *//*** ===================================================================**     Method      :  Cpu_Interrupt (component MC9S08LL64_80)****     Description :**         The method services unhandled interrupt vectors.**         This method is internal. It is used by Processor Expert only.** ===================================================================*/ISR(Cpu_Interrupt){  /* This code can be changed using the CPU bean property "Build Options / Unhandled int code" */  asm(BGND);}/*** ===================================================================**     Method      :  Cpu_DisableInt (component MC9S08LL64_80)****     Description :**         Disables maskable interrupts**     Parameters  : None**     Returns     : Nothing** ===================================================================*//*void Cpu_DisableInt(void)**      This method is implemented as macro in the header module. ***//*** ===================================================================**     Method      :  Cpu_EnableInt (component MC9S08LL64_80)****     Description :**         Enables maskable interrupts**     Parameters  : None**     Returns     : Nothing** ===================================================================*//*void Cpu_EnableInt(void)**      This method is implemented as macro in the header module. ***//*** ===================================================================**     Method      :  _EntryPoint (component MC9S08LL64_80)****     Description :**         Initializes the whole system like timing and so on. At the end **         of this function, the C startup is invoked to initialize stack,**         memory areas and so on.**         This method is internal. It is used by Processor Expert only.** ===================================================================*/extern void _Startup(void);            /* Forward declaration of external startup function declared in file Start12.c */#pragma NO_FRAME#pragma NO_EXITvoid _EntryPoint(void){  /* ### MC9S08LL64_80 "Cpu" init code ... */  /*  PE initialization code after reset */  /* Common initialization of the write once registers */  /* SOPT1: COPE=0,COPT=1,STOPE=0,??=0,??=0,??=0,BKGDPE=1,RSTPE=1 */  setReg8(SOPT1, 0x43);                   /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1,BGBDS=0,BGBE=0 */  setReg8(SPMSC1, 0x1C);                  /* SPMSC2: LPR=0,LPRS=0,LPWUI=0,??=0,PPDF=0,PPDACK=0,PPDE=1,PPDC=0 */  setReg8(SPMSC2, 0x02);                  /* SPMSC3: LVDV=0,LVWV=0,LVWIE=0 */  clrReg8Bits(SPMSC3, 0x38);              /*  System clock initialization */  if (*(unsigned char*)0xFFAF != 0xFF) { /* Test if the device trim value is stored on the specified address */    ICSTRM = *(unsigned char*)0xFFAF;  /* Initialize ICSTRM register from a non volatile memory */    ICSSC = (unsigned char)((*(unsigned char*)0xFFAE) & (unsigned char)0x01); /* Initialize ICSSC register from a non volatile memory */  }  /* ICSC1: CLKS=0,RDIV=0,IREFS=0,IRCLKEN=1,IREFSTEN=0 */  setReg8(ICSC1, 0x02);                /* Initialization of the ICS control register 1 */   /* ICSC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=1,ERCLKEN=1,EREFSTEN=0 */  setReg8(ICSC2, 0x06);                /* Initialization of the ICS control register 2 */   while(!ICSSC_OSCINIT) {              /* Wait until the initialization of the external crystal oscillator is completed */  }  /* ICSSC: DRST_DRS=0,DMX32=0 */  clrReg8Bits(ICSSC, 0xE0);            /* Initialization of the ICS status and control */   while((ICSSC & 0xC0) != 0x00) {      /* Wait until the FLL switches to Low range DCO mode */  }  /*** End of PE initialization code after reset ***/  __asm   jmp _Startup ;               /* Jump to C startup code */}/*** ===================================================================**     Method      :  PE_low_level_init (component MC9S08LL64_80)****     Description :**         Initializes beans and provides common register initialization. **         The method is called automatically as a part of the **         application initialization code.**         This method is internal. It is used by Processor Expert only.** ===================================================================*/void PE_low_level_init(void){  /* SCGC1: VREF2=1,TPM2=1,TPM1=1,ADC=1,VREF1=1,IIC=1,SCI2=1,SCI1=1 */  setReg8(SCGC1, 0xFF);                   /* SCGC2: DBG=1,FLS=1,IRQ=1,KBI=1,ACMP=1,TOD=1,LCD=1,SPI=1 */  setReg8(SCGC2, 0xFF);                   /* Common initialization of the CPU registers */  /* PTCD: PTCD1=1 */  setReg8Bits(PTCD, 0x02);                /* PTCDD: PTCDD1=1,PTCDD0=0 */  clrSetReg8Bits(PTCDD, 0x01, 0x02);      /* PTASE: PTASE7=0,PTASE6=0,PTASE5=0,PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */  setReg8(PTASE, 0x00);                   /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */  clrReg8Bits(PTBSE, 0xF7);               /* PTCSE: PTCSE7=0,PTCSE6=0,PTCSE5=0,PTCSE4=0,PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */  setReg8(PTCSE, 0x00);                   /* PTDSE: PTDSE7=0,PTDSE6=0,PTDSE5=0,PTDSE4=0,PTDSE3=0,PTDSE2=0,PTDSE1=0,PTDSE0=0 */  setReg8(PTDSE, 0x00);                   /* PTESE: PTESE7=0,PTESE6=0,PTESE5=0,PTESE4=0,PTESE3=0,PTESE2=0,PTESE1=0,PTESE0=0 */  setReg8(PTESE, 0x00);                   /* PTADS: PTADS7=1,PTADS6=1,PTADS5=1,PTADS4=1,PTADS3=1,PTADS2=1,PTADS1=1,PTADS0=1 */  setReg8(PTADS, 0xFF);                   /* PTBDS: PTBDS7=1,PTBDS6=1,PTBDS5=1,PTBDS4=1,??=0,PTBDS2=1,PTBDS1=1,PTBDS0=1 */  setReg8(PTBDS, 0xF7);                   /* PTCDS: PTCDS7=1,PTCDS6=1,PTCDS5=1,PTCDS4=1,PTCDS3=1,PTCDS2=1,PTCDS1=1,PTCDS0=1 */  setReg8(PTCDS, 0xFF);                   /* PTDDS: PTDDS7=1,PTDDS6=1,PTDDS5=1,PTDDS4=1,PTDDS3=1,PTDDS2=1,PTDDS1=1,PTDDS0=1 */  setReg8(PTDDS, 0xFF);                   /* PTEDS: PTEDS7=1,PTEDS6=1,PTEDS5=1,PTEDS4=1,PTEDS3=1,PTEDS2=1,PTEDS1=1,PTEDS0=1 */  setReg8(PTEDS, 0xFF);                   /* ### Shared modules init code ... */  /* ### Asynchro serial "AS1" init code ... */  AS1_Init();  __EI();                              /* Enable interrupts */}/* Initialization of the CPU registers in FLASH *//* NVPROT: FPS6=1,FPS5=1,FPS4=1,FPS3=1,FPS2=1,FPS1=1,FPS0=1,FPDIS=1 */const unsigned char NVPROT_INIT @0x0000FFBD = 0xFF;/* NVOPT: KEYEN=0,FNORED=1,??=1,??=1,??=1,??=1,SEC1=1,SEC0=0 */const unsigned char NVOPT_INIT @0x0000FFBF = 0x7E;/* END Cpu. *//*** ###################################################################****     This file was created by Processor Expert 3.07 [04.34]**     for the Freescale HCS08 series of microcontrollers.**** ###################################################################*/

 

SCI:

 

/** ###################################################################**     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.**     Filename  : AS1.C**     Project   : T1**     Processor : MC9S08LL64C_LQFP80**     Component : AsynchroSerial**     Version   : Component 02.472, Driver 01.30, CPU db: 3.00.023**     Compiler  : CodeWarrior HCS08 C Compiler**     Date/Time : 13.02.2011, 11:21**     Abstract  :**         This bean "AsynchroSerial" implements an asynchronous serial**         communication. The bean supports different settings of**         parity, word width, stop-bit and communication speed,**         user can select interrupt or polling handler.**         Communication speed can be changed also in runtime.**         The bean requires one on-chip asynchronous serial channel.**     Settings  :**         Serial channel              : SCI1****         Protocol**             Init baud rate          : 9600baud**             Width                   : 8 bits**             Stop bits               : 1**             Parity                  : none**             Breaks                  : Disabled**             Input buffer size       : 0**             Output buffer size      : 0****         Registers**             Input buffer            : SCI1D     [$0027]**             Output buffer           : SCI1D     [$0027]**             Control register        : SCI1C1    [$0022]**             Mode register           : SCI1C2    [$0023]**             Baud setting reg.       : SCI1BD    [$0020]**             Special register        : SCI1S1    [$0024]********         Used pins:**         ----------------------------------------------------------**           Function | On package           |    Name**         ----------------------------------------------------------**            Input   |     39               |  PTC0_RxD1**            Output  |     40               |  PTC1_TxD1**         ----------------------------------------------------------********     Contents  :**         RecvChar        - byte AS1_RecvChar(AS1_TComData *Chr);**         SendChar        - byte AS1_SendChar(AS1_TComData Chr);**         GetCharsInRxBuf - word AS1_GetCharsInRxBuf(void);**         GetCharsInTxBuf - word AS1_GetCharsInTxBuf(void);****     Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.**     **     http      : www.freescale.com**     mail      : support@freescale.com** ###################################################################*//* MODULE AS1. */#pragma MESSAGE DISABLE C4002 /* WARNING C4002: Result not used is ignored */#include "AS1.h"/*** ===================================================================**     Method      :  AS1_RecvChar (component AsynchroSerial)****     Description :**         If any data is received, this method returns one**         character, otherwise it returns an error code (it does**         not wait for data). This method is enabled only if the**         receiver property is enabled.**         [Note:] Because the preferred method to handle error and**         break exception in the interrupt mode is to use events**         <OnError> and <OnBreak> the return value ERR_RXEMPTY has**         higher priority than other error codes. As a consequence**         the information about an exception in interrupt mode is**         returned only if there is a valid character ready to be**         read.**     Parameters  :**         NAME            - DESCRIPTION**       * Chr             - Pointer to a received character**     Returns     :**         ---             - Error code, possible codes:**                           ERR_OK - OK**                           ERR_SPEED - This device does not work in**                           the active speed mode**                           ERR_RXEMPTY - No data in receiver**                           ERR_BREAK - Break character is detected**                           (only when the <Interrupt service>**                           property is disabled and the <Break**                           signal> property is enabled)**                           ERR_COMMON - common error occurred (the**                           <GetError> method can be used for error**                           specification)** ===================================================================*/byte AS1_RecvChar(AS1_TComData *Chr){  byte Result = ERR_OK;                /* Return error code */  byte StatReg = SCI1S1;               /* Read status register */  if (StatReg & (SCI1S1_OR_MASK|SCI1S1_NF_MASK|SCI1S1_FE_MASK|SCI1S1_PF_MASK)) { /* Is any error set? */    Result = ERR_COMMON;               /* If yes then set common error value */  } else if (!(StatReg & SCI1S1_RDRF_MASK)) { /* Is the reciver empty and no error is set? */    return ERR_RXEMPTY;                /* If yes then error */  } else {                             /* Intentionally left empty due to compatibility with MISRA rule 60*/  }  *Chr = SCI1D;                        /* Read data from the receiver */  return Result;                       /* Return error code */}/*** ===================================================================**     Method      :  AS1_SendChar (component AsynchroSerial)****     Description :**         Sends one character to the channel. If the bean is**         temporarily disabled (Disable method) SendChar method**         only stores data into an output buffer. In case of a zero**         output buffer size, only one character can be stored.**         Enabling the bean (Enable method) starts the transmission**         of the stored data. This method is available only if the**         transmitter property is enabled.**     Parameters  :**         NAME            - DESCRIPTION**         Chr             - Character to send**     Returns     :**         ---             - Error code, possible codes:**                           ERR_OK - OK**                           ERR_SPEED - This device does not work in**                           the active speed mode**                           ERR_TXFULL - Transmitter is full** ===================================================================*/byte AS1_SendChar(AS1_TComData Chr){  if (!SCI1S1_TDRE) {                  /* Is the transmitter empty? */    return ERR_TXFULL;                 /* If no then error */  }  SCI1D = (byte)Chr;                   /* Store char to the transmitter register */  return ERR_OK;                       /* OK */}/*** ===================================================================**     Method      :  AS1_GetCharsInRxBuf (component AsynchroSerial)****     Description :**         Returns the number of characters in the input buffer.**         This method is available only if the receiver property is**         enabled.**     Parameters  : None**     Returns     :**         ---             - The number of characters in the input**                           buffer.** ===================================================================*//*word AS1_GetCharsInRxBuf(void)**      This method is implemented as a macro. See header module. ***//*** ===================================================================**     Method      :  AS1_GetCharsInTxBuf (component AsynchroSerial)****     Description :**         Returns the number of characters in the output buffer.**         This method is available only if the transmitter property**         is enabled.**     Parameters  : None**     Returns     :**         ---             - The number of characters in the output**                           buffer.** ===================================================================*//*word AS1_GetCharsInTxBuf(void)**      This method is implemented as a macro. See header module. ***//*** ===================================================================**     Method      :  AS1_Init (component AsynchroSerial)****     Description :**         Initializes the associated peripheral(s) and the bean internal **         variables. The method is called automatically as a part of the **         application initialization code.**         This method is internal. It is used by Processor Expert only.** ===================================================================*/void AS1_Init(void){  /* SCI1C1: LOOPS=0,SCISWAI=0,Rsrc=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */  setReg8(SCI1C1, 0x00);               /* Configure the SCI */   /* SCI1C3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */  setReg8(SCI1C3, 0x00);               /* Disable error interrupts */   /* SCI1S2: LBKDIF=0,RXEDGIF=0,??=0,RXINV=0,RWUID=0,BRK13=0,LBKDE=0,RAF=0 */  setReg8(SCI1S2, 0x00);                  /* SCI1C2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */  setReg8(SCI1C2, 0x00);               /* Disable all interrupts */   SCI1BDH = 0x00;                      /* Set high divisor register (enable device) */  SCI1BDL = 0x37;                      /* Set low divisor register (enable device) */  SCI1C2_TE = 0x01;                     /* Enable transmitter */  SCI1C2_RE = 0x01;                     /* Enable receiver */}/* END AS1. *//*** ###################################################################****     This file was created by Processor Expert 3.07 [04.34]**     for the Freescale HCS08 series of microcontrollers.**** ###################################################################*/

 

 

Thank you

Outcomes