3 Replies Latest reply on Apr 13, 2018 5:50 AM by jett

    Problem with FreeRTOS in Psoc6

    user_1365519

      Hello I´m testing the FreeRTOS in a Psoc6 (In a Psoc 6 BLE Pioneer Kit). I have created from zero a new proyect and I have added in the build settings option the FreeRTOS-Memory Management option to my proyect. In that moment I can see the FreeRTOSConfig.h file in it.

       

      The first problem that I had was when I tried to add a task for making blink a led  to the  main_cm4.c file, it didn´t work until I added this lines at the start of the file:

       

       

      #include "FreeRTOS.h"
      #include "task.h"
      

       

      If I didn´t add these lines the compiler got  some errors when I was using the freeRTOS functions. In the example on the web It was no neccesary to add those lines.

       

      With the lines the LED blinks at the right rate.All woks as expected.

       

      This is the code in cm4 core:

      #include "project.h"
      
      
      #include "FreeRTOS.h"
      #include "task.h"
      
      
      void LED_TASK(void)
      {
        for(;;)
          {
              Cy_GPIO_Write(LED_ROJO_PORT,LED_ROJO_NUM,1);
              vTaskDelay(50);
              Cy_GPIO_Write(LED_ROJO_PORT,LED_ROJO_NUM,0);
              vTaskDelay(50);
          }
      
      
      }
      
      
      int main(void)
      {
          __enable_irq(); /* Enable global interrupts. */
      
      
          xTaskCreate(LED_TASK,"LED_TASK",400,NULL,1,0);
          vTaskStartScheduler();
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          
          for(;;)
          {
              /* Place your application code here. */
          }
      }
      
      
        
      

       

      When this was working I wanted to test the freeRTOS in the other core so I added to the main_cm0p.c file this code:

       

      #include "project.h"
      
      
      #include "FreeRTOS.h"
      #include "task.h"
      
      
      void LED_NARANJA_TASK(void)
      {
        while(1)
          {
              Cy_GPIO_Write(LED_NARANJA_PORT,LED_NARANJA_NUM,1);
              vTaskDelay(100);
              Cy_GPIO_Write(LED_NARANJA_PORT,LED_NARANJA_NUM,0);
              vTaskDelay(100);
              
          }
      
      
      }
      
      
      
      
      int main(void)
      {
          __enable_irq(); /* Enable global interrupts. */
          
           xTaskCreate(LED_NARANJA_TASK,"LED_NARANJA_TASK",400,NULL,1,0);
           vTaskStartScheduler();
          
      
           Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR); 
          
      
          for(;;)
          {
              
          }
      }
      

       

      Then I get these errors in main_cm0p.c file:

       

      Build error: undefined reference to `vTaskDelay'

      Build error: undefined reference to `vTaskStartScheduler'

      Build error: undefined reference to `xTaskCreate'

       

      In the main_cm4 file there are no errors.

       

      What  could be the problem? Is it possible to use the freeRTOS on both cores?

       

      Thak you in advance.

        • 1. Re: Problem with FreeRTOS in Psoc6
          ajya

          Hi,

           

          Currently in PSoC 6, only Cortex-M4 supports FreeRTOS.

           

          1. Once FreeRTOS PDL is enabled, building the project adds the necessary RTOS files to the project. You can customize the FreeRTOS kernel from FreeRTOSConfig.h file.

          2. For an RTOS project you need to include both "FreeRTOS.h" and "task.h" (for example: xTaskCreate is defined in  task.h/c).

           

          Please let me know if you have more questions.

           

          Thanks,

          Ajay

          • 2. Re: Problem with FreeRTOS in Psoc6
            user_1365519

            Hi Ajya,

            Do you know if in the future the cortex-M0+ core is going to support FreeRTOS too?, we are testing Psoc6 for a new design and is important for us to know all the potential of the device.

            • 3. Re: Problem with FreeRTOS in Psoc6
              jett

              Hi!

               

              It is possible to run FreeRTOS on the M0+ core. There are several places you can go on the web, and in the FreeRTOS documentation, to learn what you may need to do for that to work. For example, ARM Cortex-M, Interrupts and FreeRTOS: Part 1 | MCU on Eclipse. Erich, since he works for NXP, focuses mostly on NXP platforms, but there is a wealth of information on how it all works. Keep in mind, almost everything you will find on the web is for a single core system.

               

              The key difference with the PSoC 6 is, it is a dual core architecture. The best way to optimize the performance of a system is to build application firmware for the CM4, which is more powerful. Run Cypress or partner provided firmware on the CM0+. For example, if you want to build a secure application, the trusted execution environment is managed by the CM0+. If your design uses encrypted data, the encryption engine is on the CM0+. If you have a system that uses sensors, you can design it so that the M0+ manages the sensors, but the CM4 does all the work with the data.

               

              In this context, think of FreeRTOS, or any RTOS, as an extension of your primary application, a library (if you will) that you link in to your code to provide services you need, like tasks, scheduling, and all that good stuff. Your primary application should run on the M4.

               

              I hope this helps understand "the full potential" of the device. You CAN run FreeRTOS on the M0+. It makes more sense to run it on the M4.

               

              Jim