nrf21540 gain control

Hi All!

Hope you are doing well. I am using NCS 2.0.2 and VSCODE studio. Radio Test example using nrf52833+nrf21540(custom HW) . I want to ask a question how to control the gain of nrf21540 ? 

How to enable it in the radio test example and what will be the sequence of commands for that?

I am using a sequence of commands with only nrf52833DK to ensure FW is working. And output RSSI value is increasing.

output_power pos0dB  /3db /8db

 start_channel 20
 end_channel 60
 start_tx_carrier
 start_tx_sweep

Thanks & Regards,

Parents
  • Hi Muhammad,

    You can find the guide to use the FEM together with the Radio Test in the Radio Test documentation:
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/nrf/samples/peripheral/radio_test/README.html

    Regards,

    Hieu

  • Hi Hieu

    thank you for the response! I read this. The issue I am facing is that how to add the MPSL library into the NCS vs code. studio.Because its required to set the gain of nrf21540. Can you please refer to some examples available for that?

    Thanks & Regards,

    Muhammad Usman

  • HI Hieu 

    Again thank you for your concern and support. I will try to enable it as per your instructions. Facing some issues. Will try to update you on this.

    Thanks & Regards,

  • Hi Hieu

    Thank you for your support and response! I am facing the same issue.

    when 

    Thus, if you build for a board with nrf_radio_fem, CONFIG_FEM and consequently CONFIG_MPSL and CONFIG_MPSL_FEM_ONLY should be enabled on their ow

     

     I set the board "nrf21540_nrf52840" instead of nrf52833DK

     I got the following error!  for build2

    and 

    Can you please help me where is the issue ? 

    Thanks & Regards,

    Muhammad Usman

  • Hi Hieu

    One more observation, when I updated the NCS to 2.3.0. It Enabled the following options.

    In kconfig options:

    .conf file

    But when I restarted the Vscode studio above options were disabled. Can you please also help me in this regard where is the issue?

    Thanks & Regards

    Muhammad Usman

  • Hi Muhammad,

    Muhammad Usman said:

     I set the board "nrf21540_nrf52840" instead of nrf52833DK

     I got the following error!  for build2

    Looking at the error, I guess that you are working with a standalone project you created based on the radio_test sample. However, the radio_test sample does not work that way. You will need to build it from its location within the nRF Connect SDK.

    Muhammad Usman said:
    But when I restarted the Vscode studio above options were disabled. Can you please also help me in this regard where is the issue?

    Firstly, I don't understand what you mean by the above options being disabled. Do you mean that you cannot set them for some reasons? Or do you mean their values are reset somehow?

    If it's their values getting reset, please check if you are using the Save or Save to file button. "Save" only stores the changes to the <build folder>/zephyr/.config file, while only "Save to file" would store the changes to your prj.conf file for subsequent builds.

    Secondly, I see that you are updating CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA and CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTB. Do you fully understand what those configurations do? They refer to the actual POUTA and POUTB in your nRF21540, which can be one-time configured (it's only once over the chip's entire lifetime).

    The factory default of POUTA is 20dB and of POUTB is 10dB. Unless you have performed the one-time configuration of the nRF21540 I mentioned above, then these cannot be changed.

    Related to that, CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB can only be either the value of POUTA or POUTB.

    For more information regarding the two output levels, please refer to the nRF21540 Product Specification.

    Regards,

    Hieu

  • Hi Hieu

    Thank you again for your response and help.

    Looking at the error, I guess that you are working with a standalone project you created based on the radio_test sample. However, the radio_test sample does not work that way. You will need to build it from its location within the nRF Connect SDK.

    Thank you I tried your option and it worked for me for "nrf21540_52840".

    Will that option also work for "52833DK"?

    I added the following lines in  prj.conf file

    CONFIG_FEM=y
    
    CONFIG_MPSL=y
    
    CONFIG_MPSL_FEM=y
    
    CONFIG_MPSL_FEM_ONLY=y      #GPIO/ SPI control features 
    
    
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    
    CONFIG_MPSL_FEM_POWER_MODEL=y

    I tried for 52833DK by selecting the board from add build configuration but got the following warnings.

    warning: MPSL_FEM (defined at C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:37) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: MPSL_FEM_ANY_SUPPORT (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM and/or look up MPSL_FEM in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL (defined at
    C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:132) was assigned the value 'y' but got the value 'n'.
    Check these unsatisfied dependencies: (MPSL_FEM_NRF21540_GPIO || MPSL_FEM_NRF21540_GPIO_SPI) (=n),
    MPSL_FEM (=n), (MPSL_FEM || MPSL_FEM_PIN_FORWARDER) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL
    and/or look up MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL in the menuconfig/guiconfig interface. The
    Parsing C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/Kconfig
    Loaded configuration 'C:/ncs/v2.3.0/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
    Merged configuration 'c:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/prj.conf'
    Configuration saved to 'C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/build_1/zephyr/.config'
    Kconfig header saved to 'C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/build_1/zephyr/include/generated/autoconf.h'
    Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices
    sections of the manual might be helpful too.
    
    
    warning: MPSL_FEM_POWER_MODEL (defined at C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:154) was
    assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: MPSL_FEM (=n).
    See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_POWER_MODEL and/or look up
    MPSL_FEM_POWER_MODEL in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    
    warning: The choice symbol MPSL_FEM_NRF21540_GPIO_SPI (defined at
    C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:70) was selected (set =y), but no symbol ended up as the
    choice selection. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_NRF21540_GPIO_SPI and/or look up
    MPSL_FEM_NRF21540_GPIO_SPI in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.

    And CONFIG_FEM is also disabled

    is there any other thing I am missing? Because I have to run the code on custom Hardware nrf52833_nrf21540.

    Or do u have any other option for that?

    Firstly, I don't understand what you mean by the above options being disabled. Do you mean that you cannot set them for some reasons? Or do you mean their values are reset somehow?

     Thank you, now I understand my mistake after your response!

    Thanks & Regards,

    Muhammad Usman 

Reply
  • Hi Hieu

    Thank you again for your response and help.

    Looking at the error, I guess that you are working with a standalone project you created based on the radio_test sample. However, the radio_test sample does not work that way. You will need to build it from its location within the nRF Connect SDK.

    Thank you I tried your option and it worked for me for "nrf21540_52840".

    Will that option also work for "52833DK"?

    I added the following lines in  prj.conf file

    CONFIG_FEM=y
    
    CONFIG_MPSL=y
    
    CONFIG_MPSL_FEM=y
    
    CONFIG_MPSL_FEM_ONLY=y      #GPIO/ SPI control features 
    
    
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    
    CONFIG_MPSL_FEM_POWER_MODEL=y

    I tried for 52833DK by selecting the board from add build configuration but got the following warnings.

    warning: MPSL_FEM (defined at C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:37) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: MPSL_FEM_ANY_SUPPORT (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM and/or look up MPSL_FEM in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL (defined at
    C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:132) was assigned the value 'y' but got the value 'n'.
    Check these unsatisfied dependencies: (MPSL_FEM_NRF21540_GPIO || MPSL_FEM_NRF21540_GPIO_SPI) (=n),
    MPSL_FEM (=n), (MPSL_FEM || MPSL_FEM_PIN_FORWARDER) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL
    and/or look up MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL in the menuconfig/guiconfig interface. The
    Parsing C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/Kconfig
    Loaded configuration 'C:/ncs/v2.3.0/zephyr/boards/arm/nrf52833dk_nrf52833/nrf52833dk_nrf52833_defconfig'
    Merged configuration 'c:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/prj.conf'
    Configuration saved to 'C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/build_1/zephyr/.config'
    Kconfig header saved to 'C:/ncs/v2.3.0/nrf/samples/peripheral/radio_test/build_1/zephyr/include/generated/autoconf.h'
    Application Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices
    sections of the manual might be helpful too.
    
    
    warning: MPSL_FEM_POWER_MODEL (defined at C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:154) was
    assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies: MPSL_FEM (=n).
    See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_POWER_MODEL and/or look up
    MPSL_FEM_POWER_MODEL in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    
    warning: The choice symbol MPSL_FEM_NRF21540_GPIO_SPI (defined at
    C:/ncs/v2.3.0/nrf\subsys\mpsl\fem/Kconfig:70) was selected (set =y), but no symbol ended up as the
    choice selection. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MPSL_FEM_NRF21540_GPIO_SPI and/or look up
    MPSL_FEM_NRF21540_GPIO_SPI in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.

    And CONFIG_FEM is also disabled

    is there any other thing I am missing? Because I have to run the code on custom Hardware nrf52833_nrf21540.

    Or do u have any other option for that?

    Firstly, I don't understand what you mean by the above options being disabled. Do you mean that you cannot set them for some reasons? Or do you mean their values are reset somehow?

     Thank you, now I understand my mistake after your response!

    Thanks & Regards,

    Muhammad Usman 

Children
  • Hi Muhammad,

    If you recall what I said in my earlier reply, it would make sense:

    Hieu said:

    Just want to share I understood the reason CONFIG_FEM was not set to y. Its dependency MPSL_FEM_ANY_SUPPORT was not set for boards without FEMs.

    The board nrf52833dk_nrf52833, which you are likely using, does not have a FEM defined in its Device Tree Specification (DTS).

    If you are using the nRF21540 EK as a shield on top of the nRF52833 DK, you can get the FEM defined in the final compiled DTS by building with the -DSHIELD=nrf21540_ek argument. 

    You can find that documented in the Radio Test sample documentation.

    In the future, where you have a custom board, you have two options.

    1. Use DTS Overlay to "overlay" the nrf52833dk_nrf52833 board definition into your custom board

    2. Create your custom board.

    To prepare for that, I recommend you read and fully understand the following pages (and their subpages):

    Devicetree HOWTOs — Zephyr Project Documentation (nordicsemi.com)

    Board support — nRF Connect SDK 2.3.99 documentation (nordicsemi.com)


    The two pages above are just on the DTS topic. If possible, I recommend you read the entire application development guide from Zephyr and NCS.

    Application development — nRF Connect SDK 2.3.99 documentation (nordicsemi.com)

    Application Development — Zephyr Project Documentation (nordicsemi.com)

    I understand that they are a lot. However, to realize a complete product with DFU, wireless connectivity, and custom board, you most likely would need a lot of the knowledge in those pages. Of course, some section can be skipped if they are obviously not applicable to you, such as Wi-Fi.

    Regards,

    Hieu

  • Hi Hieu!

    Again thank you so much for your support!

    You are right, I have to read and understand the basic functionality. Thank you for the links and guidance! Definitely, I will go through all these.

    In the last 2 days, I tried to enable the nrf21540 FEM module for nrf52833. I assigned the pins according to the custom board design (nrf21540+nrf52833).I want to share my work with you. Am I in the right direction?

    Here is the image which explains the configuration of the .dts .overlay file and device tree output.Now MP

    Now,

    CONFIG_MPSL=y
    CONFIG_MPSL_FEM=y
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    also enabled in the prj.conf file and "fem.h" in radio_cmd.c  and radio_test.c as well. 
    The last thing pending is to test on custom HW. Which will be available to me in 4-5 days.

    Thanks & Regards,

    Muhammad Usman

     

  • Hi Muhammad,

    I am not too confident in review things without test, but the content looks right to me. Just remember to define the SPI IF pins correctly as well.

    Are you modifying the nrf52833dk_nrf52833.dts file directly? You shouldn't do that, and just use the overlay file.

    Finally, as we discussed before, the three Kconfigs you listed should be enabled by default if your DTS work correctly, so please try not setting them explicitly, and run a build to see if they are enabled by default in the zephyr/.config file.

    On second thought, if the DTS setup does not work correctly, the Kconfigs should also just be disabled due to unsatisfied dependencies.

    Regards,

    Hieu

  • Hi Hieu,

    Thank you so much for your support! Sure i will follow all your instructions. yes, I modified the overlay file only. Will take 1-2 days to get the hardware for testing. I will update my findings soon on it.

    Thanks &  Regards,

    Muhammad Usman

  • Hi Hieu!

    I tried the radio test example as per above mentioned configuration but the RSSI viewer is showing -38dbm when i set 0dbm gain at nrf52833 and 20dbm default gain at nrf21540. Is it possible to read the CONFREG registers of nrf21540? via Vscode studio debugger? 

    Or any other option to observe that nrf21540 is working? One more option is to view SPI signals on an oscilloscope.

    What u suggest?

    Thanks & Regards,

    Muhammad Usman

Related