How to keep GPIO status during extended sleep

Learn MoreFAQsTutorials

4 posts / 0 new
Last post
brent_zheng
Offline
Last seen:6 months 1 week ago
加入:2017-08-25 07:50
How to keep GPIO status during extended sleep

Dear Sir,

From my test, I setup a timer and set GPIO P09 output high in timer handler. I found GPIO keep high during sleep, but it will change to low when wakeup. So how to keep the gpio always high?

Thanks.

Best regards,

Brent Zheng

Device:
PM_Dialog
Offline
Last seen:6 days 16 hours ago
工作人员
加入:2018-02-08 11:03
Hi brent_zheng,

Hi brent_zheng,

The state of the pin before going to sleep, is retained but not the configuration or the functionality of the pin. When the device wake's up the periph_init() function is called in order to re-configure the pins in each wakeup and the pins return their default application state. So, if any of the GPIOs is high before going to sleep, it will stay high during sleep, and will be reconfigured in wake up by the periph_init() function. Which is the default pin state?

Thanks, PM_Dialog

bobspam@free.fr
Offline
Last seen:1 month 3 weeks ago
加入:2018-06-20 08:07
Hello

Hello

The GPIO electric state is retained thanks to a latch that is driven by the power manager. When sleep condition are met, the power manager raise-up the latch so the GPIO is not lost during sleep. At wake-up power manager does launch periph_init function.

GPIO electrical state is being retained at the pad level, the GPIO controller is not retained so the status of the GPIO must be restored in periph_init. By looking at the source code of sys_power_manager.c you will find several hooks for instance

// A user definable macro that allows application code to be added.
configPRE_SLEEP_PROCESSING( sleep_period );

that could be called before going to sleep thus allowing you to backup the GPIO states right before sleeping. By reprogramming these states in periph_init you will be able to maintain a stable state.

Difference between prvSetupHardware and periph_init is related to sleep mode. The first is called at start-up while the latter is called at each wake-up so you should split init of your peripherals between these two. The first shall receive AlwaysOn peripherals init while the latter shall receive any peripheral init that is not managed by adapters.

Best Regards

brent_zheng
Offline
Last seen:6 months 1 week ago
加入:2017-08-25 07:50
Dear Sir,

Dear Sir,

Thank you for such detailed reply. I'll check later.

Best regrards,

Brent Zheng