Hi. I'm using PCA10028, SDK10.0.0 S130.
I want to make nRF51 goes sleep mode. So I tested linked source code as below. github.com/.../main.c
It works well. But after I add this code in "ble_app_hrs_c" as below, it doesn't work.
int main(void) {
bool erase_bonds;
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
buttons_leds_init(&erase_bonds);
uart_init();
printf("Heart rate collector example\r\n");
ble_stack_init();
device_manager_init(erase_bonds);
db_discovery_init();
hrs_c_init();
bas_c_init();
// Start scanning for peripherals and initiate connection
// with devices that advertise Heart Rate UUID.
scan_start();
// Configure BUTTON1 as a regular input
nrf_gpio_cfg_input(BUTTON_1, NRF_GPIO_PIN_NOPULL);
// Configure BUTTON2 with SENSE enabled
nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
// Configure the LED pins as outputs
nrf_gpio_range_cfg_output(LED_START, LED_STOP);
nrf_gpio_pin_set(LED_1);
// If desired, change the RAM retention parameters:
NRF_POWER->RAMON = POWER_RAMON_ONRAM0_RAM0On << POWER_RAMON_ONRAM0_Pos
| POWER_RAMON_ONRAM1_RAM1On << POWER_RAMON_ONRAM1_Pos
| POWER_RAMON_OFFRAM0_RAM0Off << POWER_RAMON_OFFRAM0_Pos
| POWER_RAMON_OFFRAM1_RAM1Off << POWER_RAMON_OFFRAM1_Pos;
while(1)
{
// If BUTTON1 is pressed..
if(nrf_gpio_pin_read(BUTTON_1) == 0)
{
// Clear LED1
nrf_gpio_pin_clear(LED_1);
// Enter system OFF. After wakeup the chip will be reset, and the MCU will run from the top
NRF_POWER->SYSTEMOFF = 1;
}
}
Q1. It doesn't go to "nrf_gpio_pin_read(BUTTON_1) == 0", although i press the button.
Q2. If I want to use Only advertising or scanning, I can make other blocks go to sleep mode. Could you give me the way of that? Like example code or advice?
I hope your reply.