Hi,
In my S08PA60 design, i noticed SCI transmitter bug.
Every second, i send to the server 49 bytes, from Tx SCI1 module and TIE interrupt enabled.
First time it sends normally, but second nothing, and again. So, server receive every 2 seconds. And randomly, MCU reset.
In debug mode, step by step, all look correct, but none byte is sent.
Alternatively, if i put 1ms loop tempo just after initiate first byte, all is running perfectly. But i don't understand what happens, because there is reset some time.
Below, my init SCI, portion of main program and ISR:
Init SCI1 when MCU is starting :
/* Setup PTC6/PTC7 named "TxD"/"RxD" Serial module (SCI1) */
SCI1_BD = 22; //Select Baud rate : SBR * 16 = 347 => SBR = 22 => 57600bd
SCI1_C1 = 0b00000100;
SCI1_C2_RIE = 1;
SCI1_C2_RE = 1;
SCI1_C3 = 0b00001000; //overrun enabled
Start Tx with interrupt function :
void SCI_TE_ON(void)
{
U8 u8status;
u8status = SCI1_S1; // clear the interrupt event flag
SCI1_C2_TIE = 1; // Transmit interrupt enebled
SCI1_C2_TE = 1; // Transmitter ON
u8status = SCI1_S1; // clear the interrupt event flag
}
Interrupt subroutine :
interrupt VectorNumber_Vsci1tx void SCI1_Tx (void)
{
U8 u8status;
U8 *p = (U8*)&packet;
U8 *uuid = (U8*)0x30f8; // Address of UUID
u8status = SCI1_S1; // clear the interrupt event flag
if(data_type == STANDARD && SCI_byte_ctn_Tx < SCI_nb_byte_Tx)
{
if(buffer_type == SCI_BUFFER)
{
SCI1_D = SCI_buffer_Tx[SCI_byte_ctn_Tx]; //Push byte
SCI_byte_ctn_Tx++; // and pointer for next data
}
else{...}
}
else
{
SCI_nb_byte_Tx = 0;
SCI_byte_ctn_Tx = 0;
SCI_ctn_byte_packet_TxRx = 0;
SCI_Tx_free = YES;
SCI_TE_OFF();
SCI_RE_ON();
}
}
And portion of main program :
//Send data on eth every XX seconds (for automatic raw data to send)
if(u8inc_Send_On_Eth == 1)
{
if(u8Send_On_Eth > 0 && srv_request == NO && SCI_Tx_free == YES)
{
if(PPump_state == ON && Ts >= u8TsMin) //Heating sequence is starting ?
{
rt_rawdata(); // Fill Tx Buffer
SCI_TE_ON(); // Start sending first buffer byte
dly1msU16(1); // WITHOUT THIS TEMPO, THERE IS PROBLEM
}
}
u8inc_Send_On_Eth = 0;
}
There is someting wrong with interrupt, can anyone can help me ?
Thank you
Hi @corso66,
It seems to be a problem with the receive overrun condition, please check out this community post:
Here is also a community post with a CodeWarrior v10.3 sample code that set the SCI2 at 9600:
You can find more information about this example and peripheral inside the S08 User Guide (HCS08QRUG) in the "Using the Serial Communications Interface (SCI) for the HCS08 Family Microcontrollers" section.
I hope you find this helpful, and update me on any findings.
Best regards,
Julián.