4 Replies Latest reply on Feb 12, 2020 8:21 PM by MoTa_728816

    CE219656 - PSoC 6 MCU UART using Low Level APIs; clearing interrupt

    CaKu_4284131

      I am looking at, and running, the UART_Low_Level_User_ISR code sample. I have a question about this function:

       

      /***************************************************************************//**

      * Function Name: ISR_UART

      ********************************************************************************

      *

      * Summary:

      *  This function is registered to be called when UART interrupt occurs.

      *  (Note that only RX fifo not empty interrupt is unmasked)

      *  Whenever there is a data in UART RX fifo, Get that data and Put it into

      *  UART TX fifo which will be transmitted to terminal

      ...

      void ISR_UART(void)

      {

          /* Check for "RX fifo not empty interrupt" */

          if((UART_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0)

      {

              /* Clear UART "RX fifo not empty interrupt" */

      UART_HW->INTR_RX = UART_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk;       

                 

              /* Get the character from terminal */

      read_data = Cy_SCB_UART_Get(UART_HW);

      ...

       

      Questions:

       

      1) How does bitwise AND of SCB_INTR_RX_NOT_EMPTY_Msk (0x4UL) with UART_HW->INTR_RX clear the interrupt? Also, is this the preferred way to clear the interrupt in the ISR?

       

      2) Is it even possible to clear this interrupt if the RX fifo is not empty, or it will it be redriven forever until something like Cy_SCB_UART_Get(UART_HW)empties the fifo? I'd like to defer the get.