2020-02-28 08:13 AM
Hello,
stm32F4
FreeRTOS
Cube 1.4.2
My code sometimes run pretty long osDelay. In fact "long" means "longer than watchdog"..
I thought about cutting the delay in smaller delays and call a watchdog kick after each delay. Something like this:
osStatus delay(uint32_t delay) {
#if INCLUDE_vTaskDelay
uint32_t remainingDelay = delay;
while (remainingDelay > WATCHDOG_DELAY / 2) {
TickType_t ticks = (WATCHDOG_DELAY / 2) / portTICK_PERIOD_MS;
vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */
remainingDelay -= WATCHDOG_DELAY / 2;
watchdogSignal(testTaskId);
}
TickType_t ticks = remainingDelay / portTICK_PERIOD_MS;
vTaskDelay(ticks ? ticks : 1); /* Minimum delay = 1 tick */
watchdogSignal(testTaskId);
return osOK;
#else
(void) millisec;
return osErrorResource;
#endif
}
But the thing is, I would like all the code to use this snippet, ie replacing osDelay.
BUT osDelay is not declared weak.
Do you know a way to do this without having to :
?
Or maybe, is there a better way to do this?
Thanks
Julien
2020-02-29 08:54 AM
Suggest reading this: https://stackoverflow.com/questions/13217959/how-to-use-the-watchdog-timer-in-a-rtos
I would put a watchdog reset in a software timer and make timer task the second lowest priority task next to idle task. Or that is not enough in your case?