Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

Post by Dugite » Sat Oct 12, 2019 2:23 pm

I have developed a data logger based on the Pyboard 1.1 which is running Micropython 1.11 as shown below:
Capture.JPG
Capture.JPG (25.53 KiB) Viewed 2997 times
It has the following other ICs on the board which are power switched to save power during deepsleep mode:
  • SPI Digital IO;
  • SPI ADC;
  • SPI Temperature;
  • Serial ICs;
  • Accelerometer.
I have setup pins PA0 and PC13 to wake the board from deepsleep on a rising edge as follows:

stm.mem32[stm.PWR + stm.PWR_CSR] |= 1 << 8 # enable WKUP pin on PA0.
stm.mem32[stm.RTC + stm.RTC_TAFCR] |= 1 << 0 # Tamper 1 detection enabled PC13.
machine.deepsleep()

The problem I am having is as follows:
  • If I switch off all of the other ICs in deepsleep mode, when I toggle the PA0 or PC13 pins, the microcontroller immediately wakes up as expected, including from the RTC wakeup;
  • If I keep the power enabled for the other ICs and then enter deepsleep mode the microcontroller will not wake up from either the RTC or PA0 or PC13.
Does someone know what could be stopping deepsleep wakeup from working when the other ICs have power applied? Any comments or help with this would be much appreciated :)

User avatar
ghayne
Posts: 42
Joined: Sat Jun 08, 2019 9:31 am
Location: Cwmllynfell, Wales

Re: Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

Post by ghayne » Sat Oct 12, 2019 4:56 pm

Could it be that when the other IC's are powered that they are preventing wake from deep sleep by holding Pyboard inputs high or low somehow? Just a quick idea.

EDIT: Just found this:
https://github.com/micropython/micropython/issues/3834

User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Re: Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

Post by Dugite » Sun Oct 13, 2019 3:37 am

@ghayne

PA0 is being pulled high by the SPI IO interrupt pin when in machine.deepsleep mode, but not during pyb.wfi. I am not sure what is going on here yet, but will investigate and respond when fixed :)

User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Re: Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

Post by Dugite » Fri Nov 15, 2019 2:03 pm

The problem ended up being the MCP23S17 chip has an IO-RESET pin which was not pulled high (resets on low). This meant that in deep sleep, the STM32 was no longer controlling this pin so it went low putting the chip into reset which was preventing PA0 from triggered the wake up interrupt.

The fix was to use a 100k pull-up resisitor on IO-RESET which fixed the problem.

User avatar
ghayne
Posts: 42
Joined: Sat Jun 08, 2019 9:31 am
Location: Cwmllynfell, Wales

Re: Pyboard machine.deepsleep not waking from RTC, PA0, PC13 when other ICs have power

Post by ghayne » Sun Nov 17, 2019 6:40 pm

Glad that you sorted it.

Post Reply