cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Contributor II

Hello,

I am trying FreeRTOS with CY8CKIT-062-BLE.

Please see the attached project.

Task A and Task B are scheduled by pressing SW2 after reset release, and are switched every 1 ms.

However, after pressing SW2, the start message is displayed and only TaskA is executed for about 9ms.

Why doesn't TaskA and TaskB switch for 9ms?

pastedImage_0.png

Best regards,

Yocchi

0 Likes
Reply
1 Solution
Contributor II

Hello,

Thank you for everything.

As a result of analyzing the waveform, it was found that it was working properly in configTICK_RATE_HZ units. Since it is stored in the UART FIFO and the printf heap memory, it seems that there are many process executions up to FIFO full or FIFO level. After that, UART transmission is performed to fill the FIFO space for 1 byte, so processing is performed once at the same time as UART communication.

Best regards,

Yocchi

View solution in original post

0 Likes
Reply
5 Replies
Moderator
Moderator

Hello Yoochi san,

As in the project FreeRTOS is set as priority based pre-emptive scheduler, tasks that not yield are round-robin scheduled. But relying on this round robin timing for equal distribution of time slices is not advisable. Your tasks must enter a blocked state to guarantee that to run the tasks as expected. You can add a vTaskDelay function on the task implementation.

void prvTaskA(void *pvParameters)

{

    (void)pvParameters;

    while(1)

    {

        printf("A");

        vTaskDelayUntil(1);

    }

}

Now while using printf a better way might be to use the individual tasks to create a logging task which is of low priority. These tasks can print the data to the queue which the logging task will print later after reading it.

Best Regards,
Vasanth

0 Likes
Reply
Contributor II

Hello Vasanth-san,

I understand that setting it to round robin doesn't make much sense.

I would like to know why the scheduler can't immediately round robin after starting.

And why is the task switching faster if the opening message is as follows.

    printf("=======================================================\r\n");

    printf("Started Time slice of task A and task B\r\n");

    printf("=======================================================\r\n");

pastedImage_0.png

Best regards,

Yocchi

0 Likes
Reply
Contributor II

Hello Vasanth-san,

I added the code that flips the GPIO test port when each task is performed.

After scheduling the task, I found that Task A wasn't running for 9ms, and Task A had a faster execution time.

pastedImage_0.png

  if I have many opening message

    printf("=======================================================\r\n");

    printf("Started Time slice of task A and task B\r\n");

    printf("=======================================================\r\n");

pastedImage_1.png

why?

Best regards,

Yocchi

0 Likes
Reply
Employee

Please try taskYIELD() function to make a context switching.

0 Likes
Reply
Contributor II

Hello,

Thank you for everything.

As a result of analyzing the waveform, it was found that it was working properly in configTICK_RATE_HZ units. Since it is stored in the UART FIFO and the printf heap memory, it seems that there are many process executions up to FIFO full or FIFO level. After that, UART transmission is performed to fill the FIFO space for 1 byte, so processing is performed once at the same time as UART communication.

Best regards,

Yocchi

View solution in original post

0 Likes
Reply
Top labels