4 Replies Latest reply on Apr 13, 2015 8:17 AM by user_1377889

    Help with clearing UART interrupt

    user_343349849

      I have an external interrupt attached to the SCB UART2 (PSOC 4200)

         

      The interrupt is external and using the buffer size of 8.

         

      The only interrupt flag I have enabled in the component is RX FIFO NOT EMPTY 

         

      I am having trouble understanding the correct syntax to clear the interrupt when it is fired.

         

      I want to interupt on each incoming byte an dpop it into a buffer (the code method works fine on PSOC 5LP).

         

      Here is my interrupt routine, once triggered, I get correct data in the buffer but the interrupt flag never cxlears and program stays inside the int routine forever.

         

      Any help much appreciated. Once again, variables are volatile and I have looked at several posts on Cypress but cannot understand how to clear the int. If there are more than 1 byte in buffer, do I need to explicitly read them all out or can the Clear FIFO API do this???

         

       

         

      CY_ISR(RF_INT){
        uint16 rec_data;
        uint32 intsrc;

         

        rec_data = Uart2_UartGetByte();

         

         intsrc = Uart2_GetInterruptCause();

         

         if(rec_data < 0x0100){  //no errors if MSB = 0

         

           switch(RF.Mode){

         

              case state_IDLE : 

         

                        RF.Mode = state_RECEIVING;

         

        RF.DataBytes = 0;

         

              case state_RECEIVING : 

         

        RF.Buf[RF.DataBytes++] = (uint8) rec_data;

         

        if(RF.DataBytes > (RF_MAXPACKETSIZE-1)) RF.Mode = state_IDLE;

         

              }

         

          }

         

          Uart2_CLEAR_RX_FIFO;

         

          Uart2_ClearRxInterruptSource(intsrc);

         

       }