But if multiple commands can be sent from higher priority tasks or from interrupts, make sure your queue is long enough for this. With the Timer task having the highest priority in the system, the queue can be smaller. Basically, the queue needs to hold as many command items which can be sent by other tasks (or interrupts) until they can be served by the Timer Task. The question might be: What is a useful length for that queue? Because the longer it is, the more RAM is used. The length of the queue can be configured with the following macro, while the name of the queue “TmrQ” is hard-coded in the RTOS: #define configTIMER_QUEUE_LENGTH 10 This queue is used for IPC (Inter-Process Communication) between the timer task and the other tasks of the system. The other thing that gets created is a queue for the timer task, named ‘TmrQ’: To find out what your tasks are using on the stack, see Understanding FreeRTOS Task Stack Usage and Kernel awareness Information. The timer stack size really depends on what you are doing in the timer hooks called from the timer task. I recommend giving the timer task the highest task priority in the system, otherwise, you will see some latency in the timer hook execution. #define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) #define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) The timer task name, priority and stack size can be configured with the following macros in FreeRTOSConfig.h #define configTIMER_SERVICE_TASK_NAME "Tmr Svc" Basically, it checks if a timer has been expired and calls the associated timer hook. This timer task is responsible to handle all FreeRTOS software timers in the system. In the above screenshot (Event Object column) you can see as well that the Tmr Svc is waiting for receiving an object in the TmrQ queue. Because this creates the ‘Tmr Svc’ task during vTaskStartScheduler(): If you are not using FreeRTOS software timers, set that macro to 0, otherwise, your application is using more resources than necessary. To use FreeRTOS timers, you have to turn them on with the following entry in FreeRTOSConfig.h: #define configUSE_TIMERS 1
0 Comments
Leave a Reply. |