TomE,
I am not able to get my hands on any oscilloscope, but I have a STRONG feeling that 5% limitation you mention is correct. When I try to fix the Baud rate divisor in the "Device Initialization" Box to "0x0D", it gives me a 20164.923 Baud rate. I am suppose to get 19200 bps. That's actually 5.03% higher than the baud rate on my computer com port. Do you have any idea how to reduce my baud rate on the MCU side so I can generator a proper baud rate? I am attaching my code just in case you were wonder....
unsigned char SCIConfig(void){
SCI1BDH = 0x00; /*an SCI clock modulo of 4MHz*/
SCI1BDL = 0x0D; /*Configure baud rate at 19200 bps with*/
SCI1C1 = 0x00; /*8 data bits, no parity*/
SCI1C2 = 0x2C; /*Enable Tx, Rx, and RDRF interrupt*/
if (SCI1S1 & 0x80){ /*Poll TDRE flag*/
return ERROR_OK; /*TDRE set, return OK*/
}
else{
return ERROR_ERROR; /*TDRE clear, return ERROR*/
}
}
unsigned char SCIConfig(void){
SCI1BDH = 0x00; /*an SCI clock modulo of 4MHz*/
SCI1BDL = 0x0D; /*Configure baud rate at 19200 bps with*/
SCI1C1 = 0x00; /*8 data bits, no parity*/
SCI1C2 = 0x2C; /*Enable Tx, Rx, and RDRF interrupt*/
if (SCI1S1 & 0x80){ /*Poll TDRE flag*/
return ERROR_OK; /*TDRE set, return OK*/
}
else{ return ERROR_ERROR; /*TDRE clear, return ERROR*/
}
}
..main()...
{
.......
for (;
{
if(SCIIniTx == START_CYCLE){
SCIIniTx = WAIT_CYCLE;
SCIStringp=SCIString; /*Set pointer to character string*/
SCITx(*SCIStringp + Stringcase);/*Send first byte of string*/
}
}
}
in the MCU_init.c file, the SCIIsr function:
__interrupt void SCI1Isr(void)
{
if (SCI1S1 & 0x80){ /*If transmission flag is set*/
SCI1S1;
if(*(SCIStringp++) != '\0'){
if(*SCIStringp > 0xD){ //Avoid to change CR and LF characters
SCI1D=*SCIStringp + Stringcase;
}
else{
SCI1D=*SCIStringp;
}
}
else{
SCIIniTx=START_CYCLE; /*Start new transmission cycle*/
SCI1C2 &= 0x7F; /*Disable TDRE interrupt*/
}
}
if(SCI1S1 & 0x20){ /*If reception flag is set*/
SCI1S1;
if(SCI1D == 'U' || SCI1D == 'u'){
Stringcase = 0x00; /*Uppercase the character string*/
}
else if(SCI1D == 'L' || SCI1D == 'l'){
Stringcase = 0x20; /*Lowercase the character string*/
}
}
return;
}