This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to disable radio notification after enabling it

Hi,

In my application I need radio notification only during connection. When connection is dropped the peripheral goes to advertising mode and here i disable the radio notification. But it looks like the notification is not disabled since I see the current consumption is high. Is there something that I shud keep in mind regarding enabling and disabling radio notifications. The reason I know high current consumption is caused by radio notification is that this happens only when transitioning from connection->advertisement mode. whereas if the device starts in advertisement mode straight away then current consumption is in right ball park. Please see the code below on how I enable and disable notification. I am using s110 softdevice. Any help is appreciated. Thanks in advance.

 void radio_enable_notif(uint32_t type, uint32_t distance){
  uint32_t err_code;

  err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn);
  APP_ERROR_CHECK(err_code);

  err_code = sd_nvic_SetPriority(SWI1_IRQn, APP_IRQ_PRIORITY_LOW);
  APP_ERROR_CHECK(err_code);

  err_code = sd_nvic_EnableIRQ(SWI1_IRQn);
  APP_ERROR_CHECK(err_code);

  err_code = sd_radio_notification_cfg_set(type, distance);
  APP_ERROR_CHECK(err_code);
}

void radio_disable_notif(void){
  uint32_t err_code = sd_radio_notification_cfg_set(
      NRF_RADIO_NOTIFICATION_TYPE_NONE, NRF_RADIO_NOTIFICATION_DISTANCE_NONE);
  APP_ERROR_CHECK(err_code);

  err_code = sd_nvic_DisableIRQ(SWI1_IRQn);
  APP_ERROR_CHECK(err_code);
}

Update 1: I used timeslot APIs from here to disable/enable radio notifications only when Softdevice is idle. This worked for S110 softdevice. But would not work for S130 which is used in our master devices.

Update 2: I have attached an example Radio_notification_Example.zip to reproduce the bug I have been talking about. The example builds for PCA10028 boards. The example compiles with all necessary files including softdevice. On development kit I could reproduce the bug for the s110 softdevice(used by slave) and not on s130(used by master). After running slave_example we can notice advertisement consuming low current on bootup, but after it connects and goes back to advertisement the current consumption is high. Please feel free to ask if any questions. The example I have provided is a bare minimum version of what we are trying to do on our custom boards. PS: In my set up i use GCC 5.3.1. I'm using Linux machine. Example usage -

make GCC_INSTALL_ROOT=/usr/local/gcc-arm-none-eabi-5_3-2016q1 GCC_VERSION=5.3.1 JLINK_DIR=/opt/SEGGER/JLink SLNO=682844601 clean all upload

Update 3: radio_notif.c attached as mentioned in the comment to the answer.

  • Hi. How much current are you using after disconnect? The first thing i would check is if the SWI1_IRQn is pending. This would stop you from sleeping. Check the interrupt flag with a a debugger or add

    err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn);
    APP_ERROR_CHECK(err_code);
    

    to the disable function.

  • Hey Anders,

    That was my first guess too.. I tried with clearing pending interrupt. But that did not solve the issue. And regarding current, It has constant base current of ~3mA, and goes higher during advertising and CPU tasks

  • 3mA can indicate that the chip is in debug mode. Do you see this only after the disconnect? Can you describe the current draw during initial advertising, during connection, and after DC?

  • Scenario1: After bootup the device enters scanning(radio notification not enabled) the current varies between 11mA to few uA(microamps). My scan window is 500ms with interval of 1 second. Note:If I decrease this scan window (say 10ms) much further then i can observe the device current vary from as low as 2uA to 11mA much easily)

    Scenario2: After bootup the device enters scanning and finds the peripheral and establishes connection (radio notification enabled). In connection state it draws a current ~4mA(7.5ms conn interval). Now I switch off the peripheral to trigger disconnection.The master goes back to scanning(disabling the radio notification). This time the current varies between 3mA to 12mA. I cannot observe the device falling to uA current range. Note: If I don`t enable the radio notification in connected mode, then the scanning mode power consumption is as expected. That is how I know that its the problem with enabling notification.

    I make sure after programming the devices i hard reset them to disable debug mode.

  • I see. Is the code running on a Dev Kit? If it does, i can try to run your code and see if i can figure something out

Related