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

nRF52840 with PA in arduino

Hello, currently im using feather nrf52840 board in arduino environment. I made some tests with BLE with TX power at 8 dBm and when boards are at line of sight signal is good but i have to put my boards in plastic boxes and boards sits in different rooms. In this situation connection is very underwhelming, i get disconnects, connection slows down etc its not viable whereas nrf24 with pa lna in the same situation has a rock solid connection so im assuming its the effect of PA because nrf24s without PA has the same issues as the nrf52840s.

So i looked into how can i add PA LNA and came across fanstel BT840X modules with integrated PA LNA but coding wise im not sure how to implement it. i found this topic which explains how to implement the feature: https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/pa-lna-support-in-s132

so i tried adding the given code but i got error about the  ret_code_t is not declared

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
    opt.common_opt.pa_lna.gpiote_ch_id  = gpio_toggle_ch;        // GPIOTE channel
    opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch;            // PPI channel for pin clearing
    opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch;            // PPI channel for pin setting
    // PA config
    opt.common_opt.pa_lna.pa_cfg.active_high = 1;                // Set the pin to be active high
    opt.common_opt.pa_lna.pa_cfg.enable      = 1;                // Enable toggling
    opt.common_opt.pa_lna.pa_cfg.gpio_pin    = gpio_pa_pin;      // The GPIO pin to toggle
  
    // LNA config
    opt.common_opt.pa_lna.lna_cfg.active_high  = 1;              // Set the pin to be active high
    opt.common_opt.pa_lna.lna_cfg.enable       = 1;              // Enable toggling
    opt.common_opt.pa_lna.lna_cfg.gpio_pin     = gpio_lna_pin;   // The GPIO pin to toggle

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
    APP_ERROR_CHECK(err_code);
}

then i removed this part from the code:

    ret_code_t err_code;

 
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
    APP_ERROR_CHECK(err_code);

i ended up having this part:

static void pa_lna_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
{
  

    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
    opt.common_opt.pa_lna.gpiote_ch_id  = gpio_toggle_ch;        // GPIOTE channel
    opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch;            // PPI channel for pin clearing
    opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch;            // PPI channel for pin setting
    // PA config
    opt.common_opt.pa_lna.pa_cfg.active_high = 1;                // Set the pin to be active high
    opt.common_opt.pa_lna.pa_cfg.enable      = 1;                // Enable toggling
    opt.common_opt.pa_lna.pa_cfg.gpio_pin    = gpio_pa_pin;      // The GPIO pin to toggle
  
    // LNA config
    opt.common_opt.pa_lna.lna_cfg.active_high  = 1;              // Set the pin to be active high
    opt.common_opt.pa_lna.lna_cfg.enable       = 1;              // Enable toggling
    opt.common_opt.pa_lna.lna_cfg.gpio_pin     = gpio_lna_pin;   // The GPIO pin to toggle

  
}

then i called this function pa_lna_assist(); just before start advertising and the code compiled successfully. looks like bootloader uses s140 6.1.1 version. https://github.com/adafruit/Adafruit_nRF52_Arduino/tree/f97008f76993ac162f1417cfc31f24a6343befaa/cores/nRF5/nordic/softdevice

is there any hope to make the PA LNA work before i try those fanstel modules? thanks 

Parents
  • Hi

    How are these two boxes communicating, using BLE or some proprietary 802.15.4 radio protocol? Depending on how far away from each other these devices will be, and how much interference, etc. there is in the environment, I think that an LNA/PA shouldn't be necessary for BLE at least.

    The reason you get the ret_code_t not declared error is because you haven't included the header file where it is declared in your project. I believe this should be in the sdk_errors.h file, so please include that directory to your project.

    Please also note that more than 10dBm for any radio is not legal to use commercially in Europe for any radio, so I assume this is just your personal hobby project.

    Best regards,

    Simon

Reply
  • Hi

    How are these two boxes communicating, using BLE or some proprietary 802.15.4 radio protocol? Depending on how far away from each other these devices will be, and how much interference, etc. there is in the environment, I think that an LNA/PA shouldn't be necessary for BLE at least.

    The reason you get the ret_code_t not declared error is because you haven't included the header file where it is declared in your project. I believe this should be in the sdk_errors.h file, so please include that directory to your project.

    Please also note that more than 10dBm for any radio is not legal to use commercially in Europe for any radio, so I assume this is just your personal hobby project.

    Best regards,

    Simon

Children
Related