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.

Parents Reply Children
No Data
Related