2020-03-23 07:39 AM
Using an operating system such as free-rtos, it is common to send a message from the interrupt to a thread, but if the handle to the thread is not yet created - a hard-fault is usually seen. Testing a flag in the interrupt routine activated when the system is initialized can be used, but the best solution would be to let the user code take care of the NVIC enable instead of Cube-MX. Is there a way I can achive this?
Brg
Mads-l
Solved! Go to Solution.
2020-03-23 10:09 AM
Mask all interrupts that should not be handled before FreeRTOS scheduler starts.
Especially these that call FreeRTOS API.
This can be done with __set_BASEPRI. Set it at least to configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.
Note that the parameter of __set_BASEPRI must be shifted left 4 bits (with standard ST HAL setting of __NVIC_PRIO_BITS=4)
For example if your configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY is 6:
__set_BASEPRI( 6 << (8 - __NVIC_PRIO_BITS))
When FreeRTOS scheduler starts it will automatically reset BASEPRI to 0.
If you disable interrupts completely (__disable_irq), the HAL timer tick won't run too. If you use the ST HAL libraries, you may want to leave it running.
-- pa
Thanks to @berendi and @clive !
2020-03-23 10:09 AM
Mask all interrupts that should not be handled before FreeRTOS scheduler starts.
Especially these that call FreeRTOS API.
This can be done with __set_BASEPRI. Set it at least to configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY.
Note that the parameter of __set_BASEPRI must be shifted left 4 bits (with standard ST HAL setting of __NVIC_PRIO_BITS=4)
For example if your configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY is 6:
__set_BASEPRI( 6 << (8 - __NVIC_PRIO_BITS))
When FreeRTOS scheduler starts it will automatically reset BASEPRI to 0.
If you disable interrupts completely (__disable_irq), the HAL timer tick won't run too. If you use the ST HAL libraries, you may want to leave it running.
-- pa
Thanks to @berendi and @clive !
2020-03-27 02:42 AM
Thanks Pavel, solved my problem.
2020-04-08 01:19 PM
The same can be done universally by just calling taskDISABLE_INTERRUPTS().