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

pa_lna_setup() not working

I'm attempting to using pa_lna_setup(), specifically the softdevice function sd_ble_opt_set to enable/disable the radio and an external amplifier. My application is a custom beacon that advertises on an occasional basis (multiple seconds). It toggles between broadcasting 1M PHY and coded PHY. It also inserts the battery voltage into the advertising data. Presently, the advertising cycle is triggered on a timer interrupt that has the ADC get VDD, inserts the voltage into the advertising data, and then kicks off one advertising event. It works as expected without trying to use the pa_lna functionality. When attempting to use pa_lna, my timer no longer works and there is no data being advertised, though for some reason the bsp_indication_set(BSP_INDICATE_ADVERTISING) LED is still flashing. 

int main(void)
{
  log_init();
  timers_init();
  leds_init();
  power_management_init();
  saadc_init();
  saadc_sampling_event_init();
  ble_stack_init();
  ble_log_mac_address();

  saadc_sampling_event_enable();
  SEGGER_RTT_WriteString(0, "SAADC started.\n");
  pa_lna_setup();

  advertising_start();
  SEGGER_RTT_WriteString(0, "Beacon started.\n");

  // Enter main loop.
  for (;;)
  {
    NRF_LOG_FLUSH();
    idle_state_handle();
  }
}

static void pa_lna_setup(void)
{
  uint32_t err_code;
  nrf_gpio_cfg_output(APP_PA_PIN);
  nrf_gpio_pin_clear(APP_PA_PIN); //
  nrf_gpio_cfg_output(APP_LNA_PIN);
  nrf_gpio_pin_clear(APP_LNA_PIN); //

  static ble_opt_t pa_lna_opts =
      {
          .common_opt =
              {
                  .pa_lna =
                      {
                          .pa_cfg =
                              {
                                  .enable = 1,
                                  .active_high = 1,
                                  .gpio_pin = APP_PA_PIN},
                          .lna_cfg =
                              {
                                  .enable = 1,
                                  .active_high = 1,
                                  .gpio_pin = APP_LNA_PIN},
                          .ppi_ch_id_set = APP_AMP_PPI_CH_ID_SET,
                          .ppi_ch_id_clr = APP_AMP_PPI_CH_ID_CLR,
                          .gpiote_ch_id = APP_AMP_GPIOTE_CH_ID}}};
  NRF_GPIO->DIRSET |= (1 << APP_PA_PIN) | (1 << APP_LNA_PIN);
  err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &pa_lna_opts);
  APP_ERROR_CHECK(err_code);
}

static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(1);

  memset(&advdata, 0, sizeof(advdata));

  advdata.name_type = BLE_ADVDATA_NO_NAME;
  advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
  advdata.p_manuf_specific_data = &manuf_specific_data;

  // Initialize advertising parameters (used when starting advertising).
  memset(&m_adv_params, 0, sizeof(m_adv_params));
  m_adv_params.scan_req_notification = 0;
  m_adv_params.p_peer_addr = NULL; // Undirected advertisement.
  m_adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
  m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL;
  m_adv_params.duration = 0; // Never time out.
  m_adv_params.max_adv_evts = 1;

  if (use_coded)
  {
    m_adv_params.primary_phy = BLE_GAP_PHY_CODED;
    m_adv_params.secondary_phy = BLE_GAP_PHY_CODED;
    m_adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
    use_coded = false;
  } 
  else
  {
    m_adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
    m_adv_params.secondary_phy = BLE_GAP_PHY_1MBPS;
    m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
    use_coded = true;
  }

  err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
  APP_ERROR_CHECK(err_code);

  err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
  APP_ERROR_CHECK(err_code);

  err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
  APP_ERROR_CHECK(err_code);

Parents Reply Children
No Data
Related