-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from baoshi/master
Update standby examples and add implementation notes.
- Loading branch information
Showing
4 changed files
with
107 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
# the deepest slumber | ||
|
||
**WARNING: You MUST hard-reboot the CH32V003 to allow it to go into deep sleep. You cannot go from flashing to deep sleep without a hard power cycle.** | ||
|
||
This example serves to show how to put the CH32V003 into its lowest power state (standby) and have it wake with a button press. | ||
|
||
Power consumption should be around 10uA. | ||
Power consumption should be around 9uA. | ||
|
||
To enter 10uA standby mode you must perform these steps: | ||
|
||
1. GPIOs other than the wake up pin can be set to either input or output mode (see notes). | ||
2. Set GPIO(s) for wake up to input mode with appropriate pull up/down. | ||
3. Enable AFIO clock and set AFIO_EXTICR to the wakeup channel. | ||
4. Configure EXTI event. | ||
5. Set PWR_CTLR_PDDS bit in PWR_CTLR (Setting PWREN in RCC_APB1PCENR is not required hum?) | ||
6. Set SLEEPDEEP bit in PFIC_SCTLR | ||
7. Call __WFE() to enter standby mode. | ||
|
||
The MCU only toggles the LED and prints a message, then it goes back to sleep. | ||
The LED staying on demonstrates that GPIO keeps its state even when the rest of the mcu is in a coma. | ||
Note: | ||
* GPIOs in output mode will retain state during standby. | ||
* GPIO if set to input mode must have internal or external pulling resistor. Floating input pin will cause 100uA standby current. | ||
* Once CH32V003 enters standby mode, it won't respond to any SWDIO command, therefor cannot be reprogrammed. User must provide a way to have the processor stay awake for reprogramming, e.g. some delay at startup. | ||
* Debug circuitry will consume power. If minichlink terminal is active (including immediately after flashing), standby current will stay around 1.2mA until power cycle. | ||
|
||
Based on the groundwork of Marek M. | ||
|
||
## circuit | ||
|
||
Connect LED to PD4 (with resistor), connect button to GND and PD2. | ||
Connect button to GND and PD2. | ||
There is no debouncing but it should suffice for waking the chip. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters