Hi can anyone guide me in configuring the peripherals of nrf51822 before putting the chip into sleep? For example, timer, i/o pins, etc... which is not needed to reduce the power consumption. Thanks in advance.
Hi can anyone guide me in configuring the peripherals of nrf51822 before putting the chip into sleep? For example, timer, i/o pins, etc... which is not needed to reduce the power consumption. Thanks in advance.
Hi,
Typically you will enter an event handler which will set your chip into sleep mode, if you want to configure the chip to wake up when a pin goes high, or turn off ram retention, etc. this is where it is done.
In order to enter sleep mode you have two scenarios, with and without SoftDevice. In order to sleep when you have an active SoftDevice on your chip you will have to call sd_app_event_wait
. When sd_app_event_wait is called, the chip will enter System On low power mode. What actually happens is that code execution is stopped and the CPU is turned off. For most of the BLE examples in the nRF51 SDK, the sd_app_event_wait function is called in the main loop. More precisely, in the main loop of most BLE SDK examples, you will find function call power_manage which calls the sd_app_event_wait function in turn. In order to go active again the chip need to recieve an interrupt.
The same can be done if you do not have a SoftDevice installed by calling a function that looks something like this:
void sleep()
{
__SEV(); // Clear Event Register
__WFE(); // Wait for event
__WFE(); // Wait for event
}
Calling __WFE twice is the same as calling __WFI (wait for interrupt).
In order to manage peripherals while the system is sleeping please consult the infocenter pages for each peripheral. Most peripherals are default off in sleep mode.
Best regards,
Øyvind