issues with wakeup_X1

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ldbm
Posts: 14
Joined: Thu Apr 04, 2019 2:48 pm

issues with wakeup_X1

Post by ldbm » Thu May 21, 2020 10:05 pm

Hi @pythoncoder, or others familiar with upower

I am trying the upower lib to wake up from deepsleep using the X1 external pin as described in the micropower repo.

I have scope on my external trigger signaland it looks as expected. It is high (default), then drop to low for ~ 10-15ms, then return to high. I am hoping to capture this low to high transition to wake a pyb 1.1 (firmware 1.11) every few 10-20 sec for this test. When I run the script along these lines as main.py (to make sure it runs again after the board resets)...:

Code: Select all

from upower import wakeup_X1
wkup = wakeup_X1()
  # code omitted
wkup.enable()
if not upower.usb_connected:
    pyb.standby()
...it sometimes works, sometime not... no obvious reason I can see.

To t.shoot my physical setup, I ran it against another small program that uses machine.lightsleep instead, in a loop, and the same physical pin set as trig-in using the IRQ methods on Pin (so no upower.py lib used this time). Everything else is the same. In this case it runs as expected.

But of course with lightsleep current is ~ 780uA... while in deepsleep it was ~ 30uA ... Any idea appreciated. I haven't tried the Tamper class yet... Thx.

[Update]: Tamper method seems to work better as it wakes up the board when the ext trigger fires. However, it gives a bunch of false triggers and awake the board when the real triggering signal is not present... There are some small amplitude drops on the trigger line which may causes that... Using Tamper with edge detection or level detection does not fix the false alarms glitch...
I use the pins of the pyboard as is... no pull up resistors since I am not using any manual switch...

Also, the code base with the lightsleep and IRQ does not generate false triggers...

l.
Last edited by ldbm on Sun May 24, 2020 9:00 pm, edited 1 time in total.

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: issues with wakeup_X1

Post by shaoziyang » Fri May 22, 2020 1:38 am

You can set the WKUP mode by modify PWR register EWUP bit directly.

ldbm
Posts: 14
Joined: Thu Apr 04, 2019 2:48 pm

Re: issues with wakeup_X1

Post by ldbm » Fri May 22, 2020 6:07 pm

Isn't it what is done by upower ? I have been scrolling through it and the SM micro's document but this is quite in-depth.

ldbm
Posts: 14
Joined: Thu Apr 04, 2019 2:48 pm

Re: issues with wakeup_X1

Post by ldbm » Fri May 22, 2020 6:12 pm

[update on Tamper]:

So the Tamper approach works in terms of waking up the board on the expected signal, BUT, the unwanted spurious wakes still occur.
Looking more closely it seems that when the board is in deepsleep, something internally happens every 20-30 sec that awakes the board, even though my trigger pin (X18) is left High.

Putting a probe on V+ (power in to Pyb), I can see regular spikes (every 20-30 sec or so) that awake the board from Tamper...

Note that, if I go back to the prompt, and just run a machine.deepsleep, this blip is not there... so I suspect something is going on with the internals of the Tamper that are above my pay grade. :roll:

[Update]: the "spurious" wakes are seemingly caused by a DEEPSLEEP_Reset (evidently), caused by a WAKEUP... and not a TAMPER as returned py upower.why() ...

L.

Post Reply