Reputation: 41
I'm completely new to freeRTOS. I had two tasks set up to run sequentially and my program ran fine. However, when I added SysTick_Config and SysTick_Handler it will only run my tasks once and then I believe just sit on idleTask (not sure if thats the right terminology). How do I solve this problem so that my tasks run like they did before with systick_handler working as well?
I apologize if the question doesn't make sense please let me know if I need to elaborate.
Upvotes: 0
Views: 1613
Reputation: 93456
Strictly you are not "using freeRTOS to set up 1ms interrupt"; you are ignoring FreeRTOS and overriding its SysTick by calling the CMSIS SysTick_Config()
and overriding FreeRTOS's own SysTick_Handler()
.
SysTick (I guess this is an ARM Cortex-M) is designed for use as an RTOS timebase (the clue is kind of in the name ;-) ). If you hi-jack it the RTOS will not schedule normally.
Non-time-triggered tasks - i.e. those scheduled as a result of some interrupt other than SysTick will run, but in your case your tasks run until vTaskDelay()
which suspends the task indefinitely because you have replaced the RTOS SysTick handler.
The RTOS provides timing services so you do not need to use SysTick dirctly for low-resolution (i.e. the resolution of the RTOS tick; typically 1ms) timing.
In this case you appear to me implementing a 1ms tick. FreeRTOS already provides that for you via xTaskGetTickCount()
.
Other timing services include:
Essentially leave the CMSIS SysTick functions alone; use the RTOS timing services.
Upvotes: 0
Reputation: 2592
By default, FreeRTOS configures and uses SysTick for its own timing purposes, like periodic execution of the scheduler, software timers, blocking function timeouts etc. So, SysTick and the related interrupt aren't directly available for the user. You shouldn't alter SysTick in your user code.
There may be ways to change this default behavior (I'm not sure), but normally you shouldn't need it. FreeRTOS needs a timer and using a more capable TIM module instead of SysTick would be a waste.
Upvotes: 2