delphes wrote on Wednesday, November 07, 2018:
Dear,
Question is in the subject, does vTaskDelay is safe before Scheduler is starting of is this better to use alternate function for making delay ?
Regards
delphes wrote on Wednesday, November 07, 2018:
Dear,
Question is in the subject, does vTaskDelay is safe before Scheduler is starting of is this better to use alternate function for making delay ?
Regards
richard_damon wrote on Wednesday, November 07, 2018:
vTaskDelay won’t work before the scheduler is started, as the system tick hasn’t been started yet, and interrupts are disabled.
delphes wrote on Wednesday, November 07, 2018:
Thanks Richard, in my case STM32L4 the initTick was already called before scheduler start so my FreeRTOS timer is working, so is there are other reason linked to task that not allow me to use vTaskDelay ?
rtel wrote on Wednesday, November 07, 2018:
Calling vTaskDelay() before the scheduler starts doesn’t really have any
semantic sense as, if the scheduler has not been started, no tasks are
executing, so no task can call vTaskDelay(). Calling vTaskDelay() from
a function called by main() doesn’t make sense as its not a task.
What is the use case?
richarddamon wrote on Thursday, November 08, 2018:
initTick is NOT the call to setup the tick for FreeRTOS, that sounds like maybe part of the STMicro library (maybe they somehow support a dual use for it).
Also, as Richard Barry said, what vTaskDelay does is put the current task into the blocked state and switch to another task for the duration, that sort of is hard to do before the schedule starts, since you don’t have any task, either current or another.
If you have some initiliation that needs those sorts of delays, either you need a spin wait delay loop, or you postpone that part of the initialization until after your enable the FreeRTOS scheduler.
rtel wrote on Thursday, November 08, 2018:
initTick is NOT the call to setup the tick for FreeRTOS, that sounds
like maybe part of the STMicro library (maybe they somehow support a
dual use for it).
ST chain their tick and the FreeRTOS tick.
If you have some initiliation that needs those sorts of delays, either
you need a spin wait delay loop, or you postpone that part of the
initialization until after your enable the FreeRTOS scheduler.
There is also an intialisation hook, which runs in the context of the
timer task (which means you need to have timers enabled). It runs once
when the scheduler starts and is provided to allow you to perform
initialisation that requires the kernel. More traditional methods use
an ‘initialisation’ task that performs the initialisation then creates
all the other application tasks.