I'm trying to test out the UART peripheral on MPC5748G, but I’m stuck at where I’m trying to read data from the LINFlexD_7.BDRM.B.DATA4 data buffer.
My requirement: Try to transmit and receive 9 bytes of hex values as shown below.
TxBuffer[9] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}
I am attempting to read all 9 bytes using the above Rx ISR, but I am only receiving the first byte repeatedly, which is 0x11.
Expected Output:
TxBuffer[9] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
RxBuffer[9] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
Actual Output:
TxBuffer[9] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19};
RxBuffer[9] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11};
Could you please suggest what the issue is in the RxISR routine?
Please provide the correct Uart7_Rx_Isr routine to read valid 9 bytes and Uart7_Tx_Isr and Transmit function as well.
Please review my Uart7_Rx_Isr code below:
void Uart7_Rx_Isr (void)
{
unsigned char Channel = 7U;
unsigned char Data;
if (1 == LINFlexD_7.UARTSR.B.DRFRFE)
{
Data = LINFlexD_7.BDRM.B.DATA4;
LINFlexD_7.UARTSR.R &= UART_DRFRFE; /* Clear data reception flag W1C */
/*Save received data*/
if (BufferTxdisplay_index < UART_7_TX_MAX_LENGTH) //0 <12
{
BufferTxdisplay[BufferTxdisplay_index] = Data;
BufferTxdisplay_index++;
}
if( (BufferTxdisplay_index >= 9) )
{
BufferTxdisplay_index = 0;
}
}
}