AnsweredAssumed Answered

k64's UART2 Interrupt only gets two chars

Question asked by João Ribeiro on Nov 29, 2019
Latest reply on Nov 30, 2019 by Robin_Shen

Hello,

 

I have always used UART0 without any trouble, but now I need also to use UART2. I have configured UART2 with the MCUxpresso Peripherals tab making sure that UART2 is in Bus clock. I can send commands without any problem but the interrupt routine only gets the first two chars.

 

I am sure that the issue is a simple mistake, but I can't figure out what it is really. Do you have any hints?

 

Thank you in advance

 

Here is my interrupt handlers from UART0 and UART2

 

void UART0_RX_TX_IRQHandler(void){

uint8_t data;

if( (kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART_0_PERIPHERAL) ){

data = UART_ReadByte(UART_0_PERIPHERAL);//read the UART buffer

// If ring buffer is not full, add data to ring buffer.
if (((UART0_endRingBuffer + 1) % UART0_RING_BUFFER_SIZE) != UART0_startRingBuffer)
{
UART0_RX_RingBuffer[UART0_endRingBuffer] = data;
UART0_endRingBuffer++;
UART0_endRingBuffer %= UART0_RING_BUFFER_SIZE;
}
}
}

void UART2_RX_TX_IRQHandler(void){

uint8_t data;

if( (kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART_2_PERIPHERAL) ){

data = UART_ReadByte(UART_2_PERIPHERAL);//read the UART buffer

// If ring buffer is not full, add data to ring buffer.
if (((UART2_endRingBuffer + 1) % UART2_RING_BUFFER_SIZE) != UART2_startRingBuffer)
{
UART2_RX_RingBuffer[UART2_endRingBuffer] = data;
UART2_endRingBuffer++;
UART2_endRingBuffer %= UART2_RING_BUFFER_SIZE;
}
}
}

 

Regards

Outcomes