Skip to content

Commit 79b40cd

Browse files
committed
Update low power code in examples
1 parent d9281f5 commit 79b40cd

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

libraries/RTC/examples/Example6_LowPower_Alarm/Example6_LowPower_Alarm.ino

+4-9
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@ void goToSleep()
9191
for (int x = 0 ; x < 50 ; x++)
9292
am_hal_gpio_pinconfig(x, g_AM_HAL_GPIO_DISABLE);
9393

94-
//Power down Flash, SRAM, cache
95-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_CACHE); // Turn off CACHE
96-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_FLASH_512K); // Turn off everything but lower 512k
97-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_SRAM_64K_DTCM); // Turn off everything but lower 64k
98-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); //Turn off all memory (doesn't recover)
99-
94+
//Power down CACHE, flashand SRAM
95+
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); // Turn off CACHE and flash
96+
am_hal_pwrctrl_memory_deepsleep_retain(AM_HAL_PWRCTRL_MEM_SRAM_384K); // Retain all SRAM (0.6 uA)
97+
10098
// Keep the 32kHz clock running for RTC
10199
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
102100
am_hal_stimer_config(AM_HAL_STIMER_XTAL_32KHZ);
@@ -110,9 +108,6 @@ void goToSleep()
110108
// Power up gracefully
111109
void wakeUp()
112110
{
113-
// Power up SRAM, turn on entire Flash
114-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_MAX);
115-
116111
// Go back to using the main clock
117112
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
118113
am_hal_stimer_config(AM_HAL_STIMER_HFRC_3MHZ);

libraries/WDT/examples/Example3_WDT_LowPower/Example3_WDT_LowPower.ino

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Author: Adam Garbo
3-
Created: February 1st, 2021
3+
Created: March 26, 2021
44
License: MIT. See SparkFun Arduino Apollo3 Project for more information
55
66
This example demonstrates the combined use of the Artemis Watchdog Timer (WDT)
@@ -9,10 +9,10 @@
99
Both RTC and WDT interrupts will wake the system, print the date and time,
1010
and then re-enter deep sleep.
1111
12-
The WDT is configured to trigger every 10 seconds. If the WDT is not "pet"
12+
The WDT is configured to trigger every 10 seconds. If the WDT is not "pet"
1313
after 100 seconds, a system reset will be triggered.
14-
15-
The RTC alarm is configured to trigger every minute and enter deep sleep
14+
15+
The RTC alarm is configured to trigger every minute and enter deep sleep
1616
between interrupts. Alarm interuptswill also restart the WDT and reset
1717
the watchdog interrput counter.
1818
*/
@@ -104,11 +104,9 @@ void goToSleep()
104104
for (int x = 0 ; x < 50 ; x++)
105105
am_hal_gpio_pinconfig(x, g_AM_HAL_GPIO_DISABLE);
106106

107-
//Power down Flash, SRAM, cache
108-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_CACHE); // Turn off CACHE
109-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_FLASH_512K); // Turn off everything but lower 512k
110-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_SRAM_64K_DTCM); // Turn off everything but lower 64k
111-
//am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); //Turn off all memory (doesn't recover)
107+
//Power down CACHE, flashand SRAM
108+
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_ALL); // Turn off CACHE and flash
109+
am_hal_pwrctrl_memory_deepsleep_retain(AM_HAL_PWRCTRL_MEM_SRAM_384K); // Retain all SRAM (0.6 uA)
112110

113111
// Keep the 32kHz clock running for RTC
114112
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
@@ -123,9 +121,6 @@ void goToSleep()
123121
// Power up gracefully
124122
void wakeUp()
125123
{
126-
// Power up SRAM, turn on entire Flash
127-
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_MAX);
128-
129124
// Go back to using the main clock
130125
am_hal_stimer_config(AM_HAL_STIMER_CFG_CLEAR | AM_HAL_STIMER_CFG_FREEZE);
131126
am_hal_stimer_config(AM_HAL_STIMER_HFRC_3MHZ);
@@ -136,10 +131,10 @@ void wakeUp()
136131

137132
// Renable power to UART0
138133
am_hal_pwrctrl_periph_enable(AM_HAL_PWRCTRL_PERIPH_UART0);
139-
134+
140135
// Enable ADC
141136
initializeADC();
142-
137+
143138
// Enable ADC
144139
initializeADC();
145140

@@ -168,7 +163,7 @@ extern "C" void am_watchdog_isr(void)
168163
wdt.restart(); // "Pet" the dog
169164
}
170165
else {
171-
digitalWrite(LED_BUILTIN, HIGH); // Visual indication of system reset trigger
166+
while (1); // Wait for reset to occur
172167
}
173168

174169
watchdogFlag = true; // Set the watchdog flag

libraries/WDT/keywords.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Apollo3WDT KEYWORD1
55

66
# Functions (KEYWORD2)
77
configure KEYWORD2
8-
start KEYWORD2
9-
stop KEYWORD2
10-
restart KEYWORD2
11-
clear KEYWORD2
8+
start KEYWORD2
9+
stop KEYWORD2
10+
restart KEYWORD2
11+
clear KEYWORD2
1212
getCounter KEYWORD2
1313
configure KEYWORD2
1414
setClock KEYWORD2

0 commit comments

Comments
 (0)