2024-09-22 03:31 PM
I am looking for any advice to do with running the RTC Alarm as a wakeup source from STOP2 mode under ThreadX.
I have used the Alarm many times before on different STM MCUs without any issues.
1) Setting up the Alarm and using it within a WFI test loop without Theadx works perfectly, however the moment I use Threadx to wake from WFI I get an immediate hard-fault. No further code is executed, WFI -> hard-fault handler.
2) I have other wakeup sources enabled, EXTI interrupts from GPIOs and that works fine. The problem is solely related to the RTC interrupt when whatever the Threadx wakeup situation is.
3) I configured the Threadx Scheduler in ISR and Tread mode to see if it makes a difference -> Noop.4) I also tried waking from WFE within Threadx, using EXTI line 18 as per RM, had to set the ALARAIE bit but disabled the the RTC interrupt on the NVIC. Still hard-fault. Without setting ALARAIE no wakeup occurred.
Not sure if that is the right way to go, seems counterintuitive to having to enable the ALARAIE while trying to avoid using interrupts... (I have not yet verified this independently in a test loop).
4) Letting the full application run, with the Threadx WFI instruction disabled (e.g. Threadx does not sleep but runs in the idle loop), the Alarm Interrupt works fine too
4) Threadx Setup: Low power, Tickless, using the Sleep Enter and Sleep Exit functions.
5) Also, I have not used Threadx before, only FreeRTOS (including the RTC Alarm).
That is why I think the quirk lies somewhere there in the Threadx setup.
All the sleep preps have to be made manually like disabling the Systick else its also causing an immediate Hard-fault.
I am definitely ready for some fresh ideas :) Thank you.
2024-09-24 03:16 AM
Hello @bushbum,
Will you be able to share your project so we can try and reproduce/debug the issue from our side?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-09-24 03:22 AM
Hi @Sarra.S . Thank you for responding. I will make a smaller build and share it with you.
2024-09-24 06:23 AM
2024-12-17 01:50 AM
Hi, I am having the same issue, and i discovered it's not related to ThreadX itself, rather to the process of disabling interrupts before entering STOP2 mode (which is what ThreadX does). If you try a bare metal project without ThreadX but disabling the interrupts before entering STOP2 mode, it will HardFault as well. I Confirm that with a STM32L433 the issue does not happen in the same exact conditions. It's probabably related to a silicon issue of the U0.