How to deal with a case when user takes a battery off while BLE communication?

Nrf52832, SDK 13.0 Softdevice 132  PMIC: bq25150

I have a battery powered BLE device. When a user takes off the battery and put it back and powering on, the device does not seem start from MBR (master boot record).

I have a power button that is connected to PMIC and the PMIC will produce 1.8V for the CPU.

My questions are :

  1) Why does it seem not starting from MBR?

  2) Is there a way to start from MBR always whenever power is supplied?

Appreciated if you could help.

Parents
  • After more careful investigation, I found that the above statements are not correct.

    In fact, the bootloader is executed. However, the speed of execution is different.

    See below code.

    int main(void)
    {
    uint32_t ret_val;

    (void) NRF_LOG_INIT(NULL);

    NRF_LOG_INFO("Inside main\r\n");

    nrf_gpio_cfg_output(PIN25LED_RED);

    nrf_gpio_pin_set(PIN25LED_RED);
    nrf_delay_ms(2000);
    nrf_gpio_pin_clear(PIN25LED_RED);

    buttons_init();

    When it starts from power on button, the red light stayed about 2 seconds.

    However, when it starts from NVIC_SystemReset(), then it stayed  little about 2.5 more more seconds.

    Can anyone explain why it happens like that?

    PS: Please note that I had the delay time of 200ms before and I didn't see the red light. That was why I thought it didn't start from the bootloader. It came more apparent as I put more delay time. Please discard my original questions.

Reply
  • After more careful investigation, I found that the above statements are not correct.

    In fact, the bootloader is executed. However, the speed of execution is different.

    See below code.

    int main(void)
    {
    uint32_t ret_val;

    (void) NRF_LOG_INIT(NULL);

    NRF_LOG_INFO("Inside main\r\n");

    nrf_gpio_cfg_output(PIN25LED_RED);

    nrf_gpio_pin_set(PIN25LED_RED);
    nrf_delay_ms(2000);
    nrf_gpio_pin_clear(PIN25LED_RED);

    buttons_init();

    When it starts from power on button, the red light stayed about 2 seconds.

    However, when it starts from NVIC_SystemReset(), then it stayed  little about 2.5 more more seconds.

    Can anyone explain why it happens like that?

    PS: Please note that I had the delay time of 200ms before and I didn't see the red light. That was why I thought it didn't start from the bootloader. It came more apparent as I put more delay time. Please discard my original questions.

Children
Related