SAMB11 - going to sleep
Posted: Mon May 16, 2016 3:51 pm
I can't figure out how to get into sleep-mode. The BluSmartSDK mentions an ULP-Mode and the use of acquire/release-sleep-lock and the status of an AO_GPIO-Pin, but I can't figure out how to use it. The AON Sleep Timer example isn't helpful either.
I wrote an example program but it always sends data to my uart, seemingly ignoring the WFI-command. Is there anyone who can help?
I wrote an example program but it always sends data to my uart, seemingly ignoring the WFI-command. Is there anyone who can help?
Code: Select all
#include <asf.h>
#include "console_serial.h"
static void aon_sleep_timer_callback(void)
{
serial_write_data("Sleep Timer Overflow\n\r");
}
static void configure_aon_sleep_timer(void)
{ // Create Timer-Struct and register it in Reload-Mode with Interrupt every 10sec
struct aon_sleep_timer_config config_aon_sleep_timer;
aon_sleep_timer_get_config_defaults(&config_aon_sleep_timer);
config_aon_sleep_timer.mode = AON_SLEEP_TIMER_RELOAD_MODE;
config_aon_sleep_timer.counter = 320000;
aon_sleep_timer_init(&config_aon_sleep_timer);
}
static void configure_aon_sleep_timer_callback(void)
{
// Register Timer Callback
aon_sleep_timer_register_callback(aon_sleep_timer_callback);
//! [enable_IRQ]
NVIC_EnableIRQ(AON_SLEEP_TIMER_IRQn);
}
int main(void)
{
/* Initialize Serial Console and Sleep Timer */
serial_console_init();
configure_aon_sleep_timer();
configure_aon_sleep_timer_callback();
serial_write_data("Setting up Sleep Timer\n\r");
while(!AON_SLEEP_TIMER0->CONTROL.bit.SLEEP_TIMER_ACTIVE);
serial_write_data("DONE\n\r");
while (1)
{ // Wait for interrupt / Sleep
asm volatile ("wfi");
asm volatile ("nop");
serial_write_data("BLA\n\r");
}
}