Debuggign FreeRTOS in KDS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debuggign FreeRTOS in KDS

Jump to solution
1,395 Views
beng_
Contributor III

I've got a problem with Free RTOS and the timer service queue gettign full.

I'm usign FreeRTOS with Kinetis Design Studio - I have task aware debugging (see below for screenshots).


I've tried increasing the queue length but that doesn't stop the problem.

As I undertsand it the Timer Service queue is for timers waiting to be set, i.e. once a timer has been set it's removed from the queue (regardless of wether the timer has requried). So my thoughts are either:


a - The Timer Service Task is being blocked meanign it can't service the queue
Or
b - We're over-loading the timer task by sendign too many timers at once.

So I have two questions:


1 - Are either of the above theories plausible?
2 - How can I debug the timer task/queue and work out what's causing my issue?


<img src="https://image.ibb.co/fVu1fd/temp1.jpg" alt="temp1" border="0"></a>
<img src="https://image.ibb.co/dAAk6J/temp2.jpg" alt="temp2" border="0"></a>
<img src="https://image.ibb.co/eMEdRJ/temp3.jpg" alt="temp3" border="0"></a>

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,129 Views
BlackNight
NXP Employee
NXP Employee

Hi,

the queue is used to pass commands from other threads to the timer task. So that queue should be large enough to hold as many parallel commands you send to the queue. E.g. if you set up 10 timers before starting up the RTOS, you very likely need 10 queue elements to queue up the commands (e.g. with start timer).

Once the timers are running and if you don't call any timer API calls, the queue will be empty as the timers are handled in a private list inside the timer module.

In your screenshots your timer task has a priority assiged which looks fine. If your timer queue does not get handled even with a high timer priority, could it be that your timer callbacks are the problem? Make sure thay are not blocking. For testing purposes, have them 'empty' to find out if this is a problem.

I hope this helps,

Erich

View solution in original post

4 Replies
1,129 Views
beng_
Contributor III

Thanks for the advice.

Sorry for the slow respsone (I've been away on holiday). The problem was caused by a timer call back that could block. I'd kept all my timer call backs intentially short/small, but didn't check them for the possibility to block.

0 Kudos
1,129 Views
BlackNight
NXP Employee
NXP Employee

Hi Ben,

I have discussed the FreeRTOS timer queues here: Tutorial: Understanding and Using FreeRTOS Software Timers | MCU on Eclipse 

Maybe this helps as well?

Erich

1,130 Views
BlackNight
NXP Employee
NXP Employee

Hi,

the queue is used to pass commands from other threads to the timer task. So that queue should be large enough to hold as many parallel commands you send to the queue. E.g. if you set up 10 timers before starting up the RTOS, you very likely need 10 queue elements to queue up the commands (e.g. with start timer).

Once the timers are running and if you don't call any timer API calls, the queue will be empty as the timers are handled in a private list inside the timer module.

In your screenshots your timer task has a priority assiged which looks fine. If your timer queue does not get handled even with a high timer priority, could it be that your timer callbacks are the problem? Make sure thay are not blocking. For testing purposes, have them 'empty' to find out if this is a problem.

I hope this helps,

Erich

1,129 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Ben,

Please check your timer callback function , whether it bock .

And please have a look at the below words from FreeRTOS sit:

"

Important information on writing timer callback functions

Timer callback functions execute in the context of the timer service task. It is therefore essential that timer callback functions never attempt to block. For example, a timer callback function must not call vTaskDelay(), vTaskDelayUntil(), or specify a non zero block time when accessing a queue or a semaphore.

"

Hope it helps


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------