3 Replies Latest reply on Aug 5, 2014 10:34 AM by user_14586677

    UART Rx interrupt handling fail

    user_192910909

      Hello,

         

      I made a simple app to play with interrupt handling. In loop it increments a counter and it's value is sent to UART.

         

      When a byte is received on UART an ISR is called and the counter should be reset. By some reason the app works until a byte is received and than it hangs. The app hangs even if ISR has no code at all. Here is my code:

         

       main.c:

         

      #include <m8c.h>        // part specific constants and macros
      #include "PSoCAPI.h"    // PSoC API definitions for all User Modules
      #include <stdio.h>

      #pragma interrupt_handler uartIsrRx;

      unsigned char counter;

      void main(void)
      {
          unsigned int i;
          unsigned char str[16];
         
          M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
          UART_Start(UART_PARITY_NONE);
          UART_IntCntl(UART_ENABLE_RX_INT);
         
          while (1)       
          {
              counter++;
              csprintf(str, "c=%d\r\n", (int)counter);
              UART_PutString(str);
              for (i=0; i!=20000; i++);   
          }
      }

      void uartIsrRx(void )
      {
          counter=0;
      }

         

       

         

      UARTINT.asm:

         

       _UART_RX_ISR:

      ...
      ... 
         ;---------------------------------------------------
         ; Insert a lcall to a C function below this banner
         ; and un-comment the lines between these banners
         ;---------------------------------------------------
         
         PRESERVE_CPU_CONTEXT
         lcall _uartIsrRx
         RESTORE_CPU_CONTEXT
         reti

         

      Attachment:

         

      UART and PSoC global settings.

         

       

         

      Best Regards