I want to preface this by saying I’m very new to FreeRTOS (or any RTOS in general), and I’m looking for a way to run the setup function as a task. I want to be able to run it once and then delete the task, and I wanted to know if there are any accepted solutions.
Currently, I create the task within the setup function and then delete the task handle at the very end of the setup task, but this causes some other tasks to break.
Have you considered using the Daemon Task Startup Hook instead? If you set configUSE_TIMERS and configUSE_DAEMON_TASK_STARTUP_HOOK to 1 in FreeRTOSConfig.h, and provide a function called vApplicationDaemonTaskStartupHook(), then that function will get called automatically when the scheduler starts. If the timer/daemon task is the highest priority task in the system, that is if configTIMER_TASK_PRIORITY is set higher than any other task priority, then the function will get called before any other task runs.
I’m a little confused on how exactly this would work. Would this be the proper implementation? Would this run once on start up and then not be ran again? Can I also use this for my global variables inits and peripheral instantiations (like my LSM instance)?
I’m working in Arduino IDE with the Seeed Studio XIAO nRF52840 sense board. There have been timing issues where some portions are code are skipped within the setup in the past.
That does not make sense. The setup function is pretty much the only place in the code where there is predictable timing, so introducing any kind of multitasking there will do eherything else but improve tming.
Your fallacy here may be that serial output on the Arduino is tucked behind each loop invocation.
I have the same doubt, but i want do this with a function that can be called at any time by user, when the user need to do some hardware installation config or change the config at any time.
For example:
In a ihm the user press a virtual button in lcd called config( like the gear symbol on android ).
I would like to create a task that does not block the entire system because at least the ihm task needs to be running.
I would just do the setup configuration code in the hmi task that saw the virtual button press. Why do you need another task? You may want to send some form of notiification to other tasks that you are switching to “config” mode and those tasks wait for instructions that the new config is ready.