Data Sheet
BMD-345 - Data sheet
UBX-19039908 - R07 RF front end – PA / LNA Page 21 of 36
NRF_GPIOTE->TASKS_CLR[0] = 1; //ensure current GPIOTE pin is low
if( mode == PA_SHUTDOWN )
{
NRF_GPIOTE->CONFIG[0] = 0; //reset GPIOTE config
}
else if( mode == PA_TX )
{
NRF_GPIOTE->CONFIG[0]= 0x32503; //TX - pin p1.05, task, toggle, init low
NRF_PPI->CHENSET = 0x06; //re-enable PPI channels 1 and 2
}
else if( mode == PA_RX )
{
NRF_GPIOTE->CONFIG[0]= 0x32603; //RX - pin p1.06, task, toggle, init low
NRF_PPI->CHENSET = 0x06; //re-enable PPI channels 1 and 2
}
else if( mode == PA_BYPASS )
{
NRF_GPIOTE->CONFIG[0]= 0x32403; //MODE - pin p1.04, task, toggle, init low
NRF_PPI->CHENSET = 0x06; //re-enable PPI channels 1 and 2
}
}
Code block 1: Full dynamic method using PPI and GPIOTE
The code above requires calling pa_lna_init() during initialization and then calling either
pa_lna_set_mode(PA_TX) or pa_lna_set_mode(PA_RX) before using the radio to transmit or receive,
respectively.
pa_lna_set_mode() should also be called when switching the radio between transmit and receive
usage, specifying the required mode. PA_SHUTDOWN mode can be used to disable the PA / LNA, and
PA_BYPASS will enable the bypass mode during radio events (with reduced range and lower power
consumption). Note: it is not necessary to call pa_lna_set_mode() between packets.
Code to enable the PA / LNA with a Nordic Semiconductor SoftDevice:
static void pa_lna_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
{
ret_code_t err_code;
static const uint32_t gpio_toggle_ch = 0;
static const uint32_t ppi_set_ch = 0;
static const uint32_t ppi_clr_ch = 1;
// Configure SoftDevice PA / LNA assist
ble_opt_t opt;
memset(&opt, 0, sizeof(ble_opt_t));
// Common PA / LNA config
// GPIOTE channel
opt.common_opt.pa_lna.gpiote_ch_id = gpio_toggle_ch;
// PPI channel for pin learing
opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch;
// PPI channel for pin setting
opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch;
// PA config
// Set the pin to be active high
opt.common_opt.pa_lna.pa_cfg.active_high = 1;
// Enable toggling
opt.common_opt.pa_lna.pa_cfg.enable = 1;
// The GPIO pin to toggle
opt.common_opt.pa_lna.pa_cfg.gpio_pin = gpio_pa_pin;
// LNA config
// Set the pin to be active high
opt.common_opt.pa_lna.lna_cfg.active_high = 1;
// Enable toggling
opt.common_opt.pa_lna.lna_cfg.enable = 1;