Conversation
|
Code size report: |
| }; | ||
|
|
||
| void SNVS_HP_WRAPPER_IRQHandler(void) { | ||
| #if defined(MIMXRT117x_SERIES) |
There was a problem hiding this comment.
Suggest matching this with the IRQn macro setting that is configured similarly in 2 other places in this file, to make sure they stay in sync.
Eg at the top of this file do:
#ifdef MIMXRT117x_SERIES
#define RTC_IRQ_NUMBER SNVS_HP_NON_TZ_IRQn
#define RTC_IRQ_HANDLER SNVS_HP_NON_TZ_IRQHandler
#else
#define RTC_IRQ_NUMBER SNVS_HP_WRAPPER_IRQn
#define RTC_IRQ_HANDLER SNVS_HP_WRAPPER_IRQHandler
#endifAnd then use those macros as appropriate.
| MP_NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) { | ||
|
|
||
| // Stop a potentially active alarm. | ||
| machine_rtc_alarm_off(true); |
There was a problem hiding this comment.
Is this really necessary? I think it changes valid behaviour, eg if code manually sets an RTC alarm with the intention that it wakes the device from deepsleep, and then calls machine.deepsleep() (no args), that should continue to function (ie wake based on the manually-set alarm).
Maybe instead this line should go down inside the if (n_args != 0) { block? So that it resets the alarm before trying to set it.
There was a problem hiding this comment.
Now that the pin is pull-up, should it be PIN_MODE_IT_FALLING?
There was a problem hiding this comment.
Changed, even if it does not matter. By hardware it wakes up with a low level at the wakeup pin, no matter how it's set.
There was a problem hiding this comment.
Oh, right, so this argument is essentially unused for the wakeup pin.
Well, at least it's now matching the MIMXRT117x_SERIES case above.
Use the RTC irq handler to call the handler if required. Defining the proper IRQ handler for the IRQ table was missing. Signed-off-by: robert-hh <robert@hammelrath.com>
That makes it available for the code and it is used by machine.deepsleep(). Signed-off-by: robert-hh <robert@hammelrath.com>
machine.deepsleep(ms) works now as intended by powering down the board for ms/1000 seconds and then resetting it. That can be repeated several times. For MIMXRT10xx MCUs machine.deepsleep() works as intended. The WAKEUP pin pull-up was enabled and set to 100k to ensure a high/low transition. machine.deepsleep() does not work as intended for mimxrt1176. It can be called once and recover from deepsleep by pulling the WAKEUP_DIG pin low, but then attempts to call machine.deepsleep with or without a timeout fail until a power cycle is done. So waking up from deepsleep using the WAKEUP_DIG pin is not enabled. It is however possible to wakeup the device with >1 sec low pulse at the ONOFF pin. Signed-off-by: robert-hh <robert@hammelrath.com>
b7fa5ca to
337dc46
Compare

Summary
machine.rtc.alarm() did not work with the RT1176 MCU. The reason was, that the proper IRQ handler was not enabled. Since machine.deepsleep(timeout) uses mechanism of rtc alarm, it did not work either.
This PR also changes machine.deepsleep() without timeout for the RT1176 MCU. This option which should allow to wake up the MCU from deepsleep with a low pulse at the WAKEUP pin was not reliable. When used, it worked once, and then both deepsleep variants failed until the next power cycle. It seems to be a hardware issue. To avoid the unexpected behavior, the wakeup by the WAKEUP pin for machine.deepsleep() is disabled now for the RT1176. It is still possible to wakeup the device from deepsleep with a >1 sec long low pulse at the ONOFF pin. That works for MIMXRT10xx devices as well.
Testing
Tested with MIMXRT1020EVK, Seeed Arch Mix, Teensy 4.1, OpenMV RT1062, MIMXRT1170EVK.
Generative AI
I did not use generative AI tools when creating this PR.