Replies: 2 comments 2 replies
-
|
Looking into the nrf code I agree that both deepsleep() and lightsleep() are kind of dummy functions, just to provide a method with that name. __WFE() is wait for event, __WFI is wait for interrupt. Both interrupt and event happen on most ports after latest 1 ms. So there is not much of a sleep |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the confirmation, Robert. I’ve made a bit of progress on two fronts:
# NRF_POWER->SYSTEMOFF
machine.mem32[0x40000500] = 1However, I can’t wake up after that. I thought I had configured pin 30 going low as a wake source for that using # NRF_P0->PIN_CNF[30].DIR=Input, .INPUT=Connect, .PULL=Pullup, .DRIVE=S0S1, .SENSE=Low
machine.mem32[0x50000778] = 0b110000000000001100
# NRF_P0->DETECTMODE = Default
machine.mem32[0x50000524] = 0but tapping the button doesn’t wake it up. 🤔 Do I have to set up anything else to enable |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have recently started playing with MicroPython on an nRF52832 (1.22.0-preview compiled from source), after previously using it mainly on ESP microcontrollers. I am not familiar with the nRF52 and find the MicroPython documentation a bit lacking compared to other ports.
The board I’m using is a DS-D6 fitness tracker and I am working on the REPL via the UART on pins 22 & 23.
Right now I am trying to use low-power modes, which seems important on a small battery-powered device. Does MicroPython on the nRF52832 support any low-power modes, and how do I use them?
My somewhat confusing empirical results so far are:
machine.lightsleep()does not appear to do anything. If it sleeps at all, which I can’t tell, then only for a split second until it is woken up again by I don’t know what (maybe background activity from the SoftDevice?). This seems more like whatmachine.idle()is supposed to do.Right after a hardware reset,
machine.deepsleep()does sleep, however it’s a light sleep (which resumes where it left off), not a deep sleep (waking from which would be a reset). I can wake it up using the touch button, which pulls pin 30 low, although I didn’t explicitly set up anything about that pin, and by sending input on the UART (which also pulls a pin low, so maybe it’s the same mechanism).Once I turn on the SSD1306 display, which involves setting up
machine.SPI(0)and a couple ofmachine.Pins,machine.deepsleep()stops working, it wakes up again right away. This persists over a soft reset (^D). The only way I have found so far of getting back into a state wheredeepsleep()works ismachine.reset(). Is there a way around this?I can look at the source code and see that
lightsleep()anddeepsleep()are implemented asWFEandWFI, but I’m not familiar enough with ARM microcontroller internals to know what that means exactly and how to use it.Some preliminary googling indicates that the nRF52 does have a real deepsleep, called “System OFF”. Is there a way to enter this from MicroPython, other than poking around with
machine.mem32? And to set up wake sources for it?Beta Was this translation helpful? Give feedback.
All reactions