2024-09-09 12:36 PM
The documentation from Eclipse ThreadX states you must call context save/restore assembly routines for ISRs when using ThreadX calls (e.g. tx_thread_resume) in the ISR.
In our MX generated code, the EXTI9_5_IRQHandler is a C function, its doesn't have the ThreadX calls to save/restore.
_tx_thread_context_save
_tx_thread_context_restore
2024-09-09 01:21 PM
Only interrupt handlers that use RTOS functions must save/restore RTOS context. Imagine for example a quick handler that only reads or writes some register or variable atomically. Otherwise, generated interrupt handlers have user code sections where you can add any code.
2024-09-09 03:19 PM
well, yes, that's true, but i saw something in the MX release notes about a 'thread safe' option for ISRs, so I was wondering if adding the context save/restore was something the MX tool could do. Otherwise, i'll have to figure out how to make the assembly call to within my ISR C function. Its not the end of the world, but would be good to hear from ST.
2024-09-09 04:00 PM - edited 2024-09-09 04:16 PM
To call tx_thread_resume you have to use _tx_thread_context_save/restore. But CubeMX won't generate tx_thread_resume for you? So add all these code lines between the USER CODE BEGIN/END placeholders.
Cortex-M interrupt handling is awesomely designed. Assembly should not be needed. (like you don't need assembly to define ISR functions and return from ISR).
2024-09-11 05:43 AM