Hi Experts, I have an application run on freertosv10.1 which creates five timers using xTimerCreate() with different timeout periods. After expiry of each timer the callbacks print a message and again start the timer. Four timers are working perfectly but 5th timer calls the callback once after expiry and hangs after the start of the timer. I’ve run out of ideas on how to debug this issue. Can anyone please help ? ~~~
One possible issue is that timer callbacks aren’t supposed to block, and depending on how printf is implemented, it might not be suitable for use in a timer callback. If you use a debugger to stop the system, (and have configASSERT defined) does it show you caught on an assert, and if so which one?
Thanks for pointer. You are right.. the problem was due to printf’s in callback routine. Now I can see the timer getting started. Maybe we can document that timer callbacks should not be blocked (as a NOTE) or maybe this is basic thing which I’m not aware of 🙁 Thank you.
See https://www.freertos.org/RTOS-software-timer.html: “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. ”
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.