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.

  • Hello,

    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?

    Yes that should've been available as of NCS 2.2.

    Have a look here on how to enable it. 

    Regards,

    Elfving

  • yes Elfving,

    1. i see your link,does this mean even runtime  changable, there are only two option 10db and 20db solution for 21540:

    i see another ticket that confirm this:  nRF 21540 DK .

    2. and i try to check the output power, using demo peripheral_uart , i set CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=10 the power profile is as below:

    and i set CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=20, the power profile is as below,

    when i connect P0.17 to low and to high, it shows below ppk chart.

    which means the tx power is not correct according to our spec. 

    Regards,

    William.

  • 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

  • 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.

Related