Kindly ignore if its a blunder mistake, will someone please help me to troubleshoot the issue on receiving data using UART, I am sending a command through UART1 (baud rate 115200) and receiving the response. the command send and the response data from the other system is correct (the response is analysed using com port) , but on receiving the data bytes to an array; the first byte is received as zero. some help is highly favorable. The same code is below.
Thanks
UART1_Send((uint8_t *) Receiver_Command, 5); // Sending command
//------------------------------------------------------------------------------------------
Delay_Milli_Sec(6); // 6 ms delay for receiving the response from receiver // waiting time for collecting data and response of other device
_______________________________________________________________________________________________________________________________________________________________
void Delay_Milli_Sec(uint32_t Delay_value)
{
uint32_t Timer_Count;
Timer_Count = (120000 * Delay_value); // Count calcultion for value in milli sec
ROM_IntEnable(INT_TIMER3A);
ROM_TimerIntEnable(TIMER3_BASE, TIMER_TIMA_TIMEOUT);
ROM_TimerLoadSet(TIMER3_BASE, INT_TIMER3A, Timer_Count);
ROM_TimerEnable(TIMER3_BASE, TIMER_A);
while(DelaySet_Flag == 0)
{
// Wait Delay
}
DelaySet_Flag=0;
ROM_TimerIntDisable(TIMER3_BASE, TIMER_A); // Disable Timer3 interrupt
ROM_TimerDisable(TIMER3_BASE, TIMER_A); // Disable Timer3
}
______________________________________________________________________________________________________________________________________________________________
void
UART1_IntHandler(void)
{
Interrupt_Flag = (Interrupt_Flag | uart1_interrupt); // Global variable
Receive_Wait_Flag = (Receive_Wait_Flag | uart1_interrupt); // Global variable >> uart1 interrupt >> Receive wait flag set
static uint32_t ui32Status; // local variable >> interrupt status
static uint8_t uart1_data;
static uint32_t Max_byte=34; // initially set for 34 bytes
static uint32_t Current_Char = 0; // First data location in array
ui32Status = ROM_UARTIntStatus(UART1_BASE, true); // Get the interrrupt status.
ROM_UARTIntClear(UART1_BASE, ui32Status); // Clear the asserted interrupts.
while(ROM_UARTCharsAvail(UART1_BASE)) // Loop while there are characters in the receive FIFO.
{
uart1_data = ROM_UARTCharGetNonBlocking(UART1_BASE); // Read the next character from the UART1
if(Current_Char<Max_byte)
{
uart1_data_packet[Current_Char++] = uart1_data; // read each byte to uart1_data_packet array
if((uart1_data_packet[0]==0xf0)&&(uart1_data_packet[1]==0xf0)) // check for Receiver_Command message ID to set the byte count of the response data
{
Max_byte=34; // update count value according to the Command message ID
if(Current_Char==33)
{
Current_Char = 0; // clear array to 0 location
Receive_Wait_Flag &= 0xfd;
}
}
else if((uart1_data_packet[0]==0xaa)&&(uart1_data_packet[1]==0x79))
{
Max_byte=4; // update count value according to the Command message ID
if(Current_Char==3)
{
Current_Char = 0; // clear array to 0 location
Receive_Wait_Flag &= 0xfd;
}
}
else
{
Current_Char=0;
}
}
}
}