AnsweredAssumed Answered

UART IRQ question

Question asked by Brian Smith on May 26, 2019
Latest reply on May 29, 2019 by Mark Butcher

Hello,

 

I'm working with FRDM-K22F and i'm developing my own lib to control it but i'm struggling with IRQ which can be called from rx and tx.

 

The problem is that i want to handle non-blocking read and also non blocking write(both uses interrupt)

 

 

void UART2_RX_TX_IRQHandler(void)
{
         if(UART2->S1 & UART_S1_RDRF_MASK)
         {
                  circular_buff_put(internal_RX_UART_handle, UART2->D);
         }

         if(UART2->S1 & UART_S1_TDRE_MASK)
         {
                  UART_transferNonBlocking(UART2,internal_TX_UART_handle);
         }      
}

Problems starts when IRQhandler is invoked by RX, both flags RDRF and TDRE will be active but i dont want to send data unless interrupt was caused by TX. I could use else if statement and that "solves" the problem temporary.

 

Now let's assume there was interrupt caused by RX and TX almost at exact same time, would be UART2_RX_TX_IRQHandler called twice or there is small chance i would have to handle 2 interrupts in 1 handler?

Outcomes