3 Replies Latest reply on Apr 22, 2019 10:16 PM by mikl_1530731

    Modus Toolbox FreeRTOS UART

    mikl_1530731

      Howdy all!

       

      I was using PSoC Creator 4.x and followed Allan's videos to create a FreeRTOS task that allowed me to write to and read from the KitProg UART on SCB5.  It worked well and I allowed the User I/O task to pend until I got an Rx Interrupt from the UART.  We've switched over to Modus Toolbox v1.1 and I'm trying to recreate that functionality.  The transmits work great but for the life of me I can't figure out how to set up the UART Rx interrupt.  The code I used in PSoC Creator doesn't seem to work and Allan's new videos don't show the UART Rx Receive interrupt.  Any clues?

       

      Thanks,

      Michael

       

      In PSoC Creator I did the following:

       

      In main before starting the User_IO_Task:

          __enable_irq(); /* Enable global interrupts. */

       

       

          /* Place your initialization/startup code here (e.g. MyInst_Start()) */

          UART_DGB_Init( );

       

      And then in the task:

       

      void UART_DGB_Init( void )

      {

          UART_DBG_Start();

          setvbuf( stdin, NULL, _IONBF, 0 );

      }

       

      static void UART_Isr()

      {

          //Disable & clear the interupt

          Cy_SCB_SetRxInterruptMask( UART_DBG_HW, 0 );

          Cy_SCB_ClearRxInterrupt( UART_DBG_HW, CY_SCB_RX_INTR_NOT_EMPTY);

          NVIC_ClearPendingIRQ( (IRQn_Type) UART_DBG_SCB_IRQ_cfg.intrSrc);

         

          // if the semaphore causes a task switch you should yield to the task

          BaseType_t xHigherPriorityTaskWoken;

          xHigherPriorityTaskWoken = pdFALSE;

          xSemaphoreGiveFromISR( uartSemaphore, &xHigherPriorityTaskWoken ); // Tell the UART thread

          if (xHigherPriorityTaskWoken != pdFALSE)

          {

              portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

          }

      }

       

      void User_IO_Task( void *arg)

      {

          (void)arg;

                 

          uartSemaphore = xSemaphoreCreateBinary( );

         

          // Configure the interuppt handler

          (void) Cy_SysInt_Init( &UART_DBG_SCB_IRQ_cfg, &UART_Isr );

          NVIC_EnableIRQ((IRQn_Type) UART_DBG_SCB_IRQ_cfg.intrSrc);

          Cy_SCB_SetRxInterruptMask( UART_DBG_HW, CY_SCB_RX_INTR_NOT_EMPTY);

             

          while (1)

          {

              xSemaphoreTake(uartSemaphore, portMAX_DELAY);

             

              while (Cy_SCB_UART_GetNumInRxFifo(UART_DBG_HW))

              {

                  char c = getchar();

                  ...