21540 how to use api for spi to control tx power

hi support team,

i have looked into our devzone, but didn't see how to use spi to control 21540 tx power dynamiclly.

seems there is no demo or source code can explain how to do it.

i can see fem_nrf21540_gpio_spi_configure() in mpsl_fem_nrf21540_gpio.spi.c, but don't know how to change tx power dynamiclly.

and by the way i have seen this ticket: SPI bus need to be dedicated to nRF21540? , it says"Current nRF21540 SW solution does not support SPI control, it relies on GPIO control." , have we finished this software?

Regards,

William.

Parents Reply
  • 1. So I believe that is right, in that the nRF21 only has the option to switch between 10 and 20dB. Though that is just the static fem gain. 

    The way this job is divided between the FEM and the nRF depends on what you are using as a static FEM gain. Then the SoC TXPOWER is changed to compensate for the remainder such that TXPOWER+FEM gain <= CONFIG_BT_CTRL_TX_PWR_ANTENNA. So for instance if you happened to be using the nRF52840, and have set a static 20dB gain in the FEM, and set CONFIG_BT_CTRL_TX_PWR_ANTENNA=15dBm, you'll only get 12dBm on the antenna, since -8dBm is the closest you can get on the '840.

    For this calculation to work though, the nRF needs to know how much gain is set on the FEM. You can set that on the dts node using tx-gain-db. 

    You can read what TXpower the NRF is providing by for instance reading the TXPOWER register

    I think you set tx power dynamically with int fem_tx_power_control_set(fem_tx_power_control tx_power_control)

    2. I guess offloading some of the gain to the fem pays off power consumption wise.. could you expand on what P0.17 is doing?

    Regards,

    Elfving

Children
  • thanks Elfving,

    you helps me a lot. 

    1. P0.17 in 21540dk is mode pin to select POUTA or POUTB.

    2. it makes sense that TXPOWER+FEM gain <= CONFIG_BT_CTRL_TX_PWR_ANTENNA.

    Do we have link on 

    CONFIG_BT_CTLR_TX_PWR_ANTENNA in our document 

    3. and now when i set 

    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB 10 and 
    CONFIG_BT_CTLR_TX_PWR_ANTENNA  28 the TXPOWER register shows value plus_8db.the ppk shows below:
    4. but when i set CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB 20and 
    CONFIG_BT_CTLR_TX_PWR_ANTENNA  28
    the TXPOWER register shows value 0db.
    C:\ncs\ncsv2.9.0\test\peripheral_uart>nrfjprog --memrd 0x4000150c
    0x4000150C: 00000000 |....|
    the ppk shows as below: the current is 17mA in average. it seems wrong.
    there must be a table for those combination of those parameters, right?
    my purpose is to test 10db 38mA current, and 110mA in 20db from our 21540 spec.
    Regards,
    William.
  • So when you use the SPI then the mode pin should not be in use. You should let the SW do all the work and just select the antenna power as the algorithms will adjust both the FEM gain and the SoC power automatically. Remember the maximum output power with the nRF21540 is 21dBm so selecting 28 is an illigal value so should result in an error.

  • yes Paka,

    well, my purpose is to testing 21540 20db 110+mA current and 10db 30+mA current with 21540dk,so right now, i can't see the result corrent.

    what should i do to with following parameter?

    CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=20
    #CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    #CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
    #CONFIG_MPSL_FEM_POWER_MODEL=y
    CONFIG_BT_CTLR_TX_PWR_ANTENNA=20

    and after programing  the TXPOWER is 0, which means the 52840 0db internally.

    the current is 16mA. Anything wrong in my side?

    Regards,

    William.

  • So if you have 20dB gain and want 20dBm then the output power of the SoC radio will be 0dBm. When measuring the current, are you sure the FEM power is included in the measurements? Note that since the nRF21540 doesn't have bypass mode then if you have RF going to the antenna then you are using the PA (unless the signal is really, really weak, they it can be leakage).

    Note: the nRF21540 curren doesn't go through the P22/P23 on the nRF21540-DK, those will only measure the current used by the nRF52840.

Related