Skip to content

mimxrt/machine_rtc: Enable rtc.alarm for RT1176 and fix deepsleep. - #19641

Open
robert-hh wants to merge 3 commits into
micropython:masterfrom
robert-hh:mimxrt_alarm
Open

mimxrt/machine_rtc: Enable rtc.alarm for RT1176 and fix deepsleep.#19641
robert-hh wants to merge 3 commits into
micropython:masterfrom
robert-hh:mimxrt_alarm

Conversation

@robert-hh

Copy link
Copy Markdown
Contributor

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.

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>
@robert-hh

Copy link
Copy Markdown
Contributor Author

The fix for rtc.alarm() is simple and was easy. I tried for a while to get wakeup by the WAKEUP Pin working for the RT1176. Even if some fixes are mentioned in the NXP forum, none of the worked.

@github-actions

Copy link
Copy Markdown

Code size report:

Reference:  extmod: Add USB Network (NCM) driver implementation. [1c3c201]
Comparison: mimxrt/modmachine: Fix machine.deepsleep(ms) for the MIMXRT1176 port. [merge of b7fa5ca]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +8 +0.002% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants