Skip to content

Commit

Permalink
Use digital pin for wake-up on C33
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Aug 23, 2024
1 parent 6fef502 commit ff125ed
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions examples/Standby_WakeFromPin/Standby_WakeFromPin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
This sketch demonstrates how you can use the Arduino_PowermManagement library to send a board to standby mode by using a GPIO pin and wake it up from another.
This sketch is universal and worksn on both Portenta C33 and H7.
On the the Portenta C33 you can select any of the supported pins (A0, A1, A2, A3, A4, A5, D4, D7) to wake up the board from standby mode,
but on the Portenta H7 only GPIO0 can be used to wake up the board from standby mode. GPIO0 is available through the High Density Connectors and you need a breakout board to access it.
On the the Portenta C33 you can select any of the supported pins (A0, A1, A2, A3, A4, A5, D4, D7) to wake up the board from standby mode.
However setAllPeripheralsPower(false) in this sketch turns off the power lane of the analog pins.
This means they cannot sink current and therefore cannot be used to wake up the device.
Hency only D4 and D7 can be used to wake up the device in this configuration.
On the Portenta H7 only GPIO0 can be used to wake up the board from standby mode. GPIO0 is available through the High Density Connectors and you need a breakout board to access it.
Requirements:
- Arduino Portenta C33, Arduino Portenta H7
Expand All @@ -15,10 +19,17 @@
Usage:
- Connect a button to GOTO_SLEEP_PIN and with a pull-up resistor to 3.3V
- Connect a button to pin PORTENTA_C33_WAKEUP_PIN if you are using the Portenta C33 or GPIO0 if you are using a Portenta H7 and with a pull-up resistor to 3.3V
(If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
For maximum power saving use external pull-up resistors.
You will need to power them separately as the 3.3V pin on the board
is turned off when the device goes to sleep and peripherals are turned off.
Alternatively, use pinMode(<pin>, INPUT_PULLUP) for the pins and connect the buttons to ground.
(If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
- Upload the provided sketch to the board
Note: On Portenta H7, you need to upload this sketch to both cores, the M7 and the M4 for it to work.
You can do so by selecting the M7 core and then the M4 core from the Tools menu in the "Target core" section.
- Press the button connected to GOTO_SLEEP_PIN to put the board into standby mode
- Press the button connected to PORTENTA_C33_WAKEUP_PIN or GPIO0 to wake up the board from standby mode
- Press the button connected to PORTENTA_C33_WAKEUP_PIN or GPIO0 on Portenta H7 to wake up the board from standby mode
- The LED will blink every second to show that the board is awake when not in standby mode
Original author: C. Dragomir (http://arduino.cc)
Expand All @@ -28,14 +39,20 @@
#include "Arduino_PowerManagement.h"


#define PORTENTA_C33_WAKEUP_PIN A3
#define PORTENTA_C33_WAKEUP_PIN D4
#define GOTO_SLEEP_PIN D0

volatile bool shouldGoToSleep = false;

Board board;

void setup() {
// When uploading this sketch to the M4 core, it just goes to standby mode.
#if defined(ARDUINO_GENERIC_STM32H747_M4)
board.standByUntilWakeupEvent();
return;
#endif

pinMode(LED_BUILTIN, OUTPUT);

// Register the sleep and wake-up pins as inputs
Expand Down

0 comments on commit ff125ed

Please sign in to comment.