Part Number: TMS570LC4357
Tool/software: Code Composer Studio
Hello,
I work with the uart of the Hercules but I have a problem. I use an array to store the bytes that recive the MCU trought the uart port, but I see that the program lost the first byte that recive.
For example, when send the secuence 1234, the MCU send trought other uart only 234, and if I send again the secuence 1234 the MCU display 2341.
I share the basic code that use in the ISR and in the main code.
int main(void)
{
/* USER CODE BEGIN (3) */
int i=0;
MCU_Init();
//sci_Restart();
while(1)
{
rx_next=0;
rx_read=0;
rxb_next=0;
rxb_read=0;
delay(10);
if(flag_Blue==1){ //Read the buffer
sciSend(BLUE,11, (unsigned char*)"\r\nbuffer!\r\n");
while(flag_Blue==1){
sciSendByte(BLUE,rx_buffer_blue[rxb_read]);
rxb_read++;
rxb_next--;
if(rxb_next==-1){
flag_Blue=0;
rxb_read=0;
rxb_next=0;
for(i=0;i<100;i++){
rx_buffer_blue[i]=0;}
}
}
}
}
void sciNotification(sciBASE_t *sci, unsigned flags)
{
if(sci==BLUE){
sciReceive(sci,1,(unsigned char *)&rx_buffer_blue[rxb_next]);
sciSendByte(BLUE,rx_buffer_blue[rxb_next]);
rxb_next++;
if(sciIsRxReady(sci)==0){
flag_Blue=1;
}
}
If you have any suggestion or question , please tell me