AnsweredAssumed Answered

Identifying UART interrupt source on KL15

Question asked by Safwat on Apr 15, 2013
Latest reply on Jun 12, 2013 by Safwat

I am using a KL15 device for my project. I am using the TDRE and RDRF interrupts for my UART. The RDRF interrupt is always turned on so that I dont miss any incoming byte. The TDRE interrupt is turned on only when I have some data in my UART buffer that needs to be sent. This is what i check inside the UART ISR

 

void UART1_IRQHandler()
{

  /* A variable to capture the Data in the RX buffer*/
  uint8_t RcvdByte;

  /* Check for the source of the interrupt */
  /* Start with checking the TDRE flag */
  if(UART1_S1 & UART_S1_TDRE_MASK)
  {
  /* Interrupt triggered due to TX buffer being empty */
     // Call a function to send some data
  }

  /* Then check the RDRF flag */
  if (UART1_S1 & UART_S1_RDRF_MASK)
  {
  /* Interrupt triggered due to Rx Buffer full */
  RcvdByte = UART1_D; // Interrupt is cleared here, so no re-entrance will occur

     // Call the function to collect the data
  }

}

 

 

When my device boots up, the RDRF interrupt is on and the TDRE interrupt is off (because there is no data to send). So now, when i receive a byte the ISR runs and finds that the TDRE flag is set (default value after reset) although it wasnt the source of the interrupt. So the function assigned the TDRE flag gets called unnecessarily. How am I able to pin point the source of the interrupt in such cases? 

Outcomes