GPIO Control of the nRF21540 FEM

I have a custom board with a nRF52840 and a nRF21540.  To control my FEM (nRF21540) I have added the following to my code to my nRF52840_nRF52840.dts file:

/ {
    nrf_radio_fem: name_of_fem_node {
       compatible  = "nordic,nrf21540-fem";
       tx-en-gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
       rx-en-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
       pdn-gpios   = <&gpio0 31 GPIO_ACTIVE_HIGH>;
       ant-sel-gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
       mode-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
 };
};
Now, in the 'main.c' file, I want to add the code to control these pins/signals.  I'm sorry this is probably so simple, but I am new to this type of configuration, and I don't what I should do next.  I don't know what to do to control the various FEM lines within the 'main.c' program.  Any help would greatly be appreciated.
Thanks,
Sheldon
  • Hi,

    The error about missing MPSL_FEM_CHOICE is because you need to set one of the three of

    • CONFIG_MPSL_FEM_NRF21540_GPIO
    • CONFIG_MPSL_FEM_NRF21540_GPIO_SPI
    • CONFIG_MPSL_FEM_SIMPLE_GPIO

    You have selected MPSL_FEM_NRF21540_GPIO but do not have MPSL_FEM_NRF21540_GPIO_SUPPORT, which I expect i s because it is not configured properly in your device tree. Have you added the FEM suppor to the device tree (either in your board fiel or in an overlay file)?

  • I don't understand.  As I showed, I did make the choice of 'CONFIG_MPSL_FEM_NRF21540_GPIO = y' and it doesn't like that (see the second thing I posted).  It told me that had dependencies and I don't know what to do about them.  Are they something I also must see with a '= y'?

    Anyway, I have looked on my oscilloscope (see the attached plot) and it does look like the RX_EN and TX_EN lines going to the nRF21540 are switching (as I set it up in my device tree overlay file).  Yet, the RF signal strength received by my nRF52840 is measured as very weak.  I don't know what I could be doing wrong on my board.

  • As an aside question: Is it possible to have the receiver spend more time with RX_EN on more?  It is always off for a short period of time quite frequently and I would like it on almost all of the time.  I miss some of the signals I want to detect and I bet it is during the 'RX_EN' low periods when they are missed.

  • Hi,

    Sheldon01 said:
    As I showed, I did make the choice of 'CONFIG_MPSL_FEM_NRF21540_GPIO = y' and it doesn't like that (see the second thing I posted)

    Here you have white space again, and that will not work. This must be wihtout white spaces.

    Sheldon01 said:
    Are they something I also must see with a '= y'?

    You need to enable it in the device tree file. You can se a reference of this for instance in the nRF52540 DK board files (search for "nrf21540" in zephyr/boards/arm/nrf21540dk_nrf52840/nrf21540dk_nrf52840.dts). I see it seems like you have done that now as you got the pins toggling.

    Sheldon01 said:
     Yet, the RF signal strength received by my nRF52840 is measured as very weak.  I don't know what I could be doing wrong on my board.

    Have you had your hardware reviewed by Nordic? If not, it makes sense to make a support case and attach your shcematics and layout fiels (as gerber). We can also do tuning of your HW. If not, it could be an hardware issue, perhaps as simple as bad antenna tuning.

    Sheldon01 said:
    As an aside question: Is it possible to have the receiver spend more time with RX_EN on more?  It is always off for a short period of time quite frequently and I would like it on almost all of the time.

    You could control it manually instead of MPSL if you want it on all the time (refer to the docuemtation I linked to in my first post). But that would incerase the current consumption, and the MPSL knows when the radio is in use, so the most efficient is to leave controlling the FEM up to MPSL.

  • I have just done the most telling experiment yet:

    I removed the nRF21540 IC from my board and simply added a thin wire to link the antenna to the TRX pin.  When I feed in a -20dBm signal to my system (that now goes directly to the nRF52840) I get close to an RSSI value of -20dBm.  When I have the nRF21540 IC in place, I read a RSSI of -50dBm (or worse).  It gets weaker with the FEM circuit in place when it should be much stronger!.  I think that there must be something wrong with the control signals I am sending to my nRF21540.

    I may send in my schematic and board layout but I am quite sure that they are not the problem.  I still believe that I must be sending the FEM incorrect control signals.  It's like nRFnRF52840 gets nothing from the FEM but only a weak signal leaks in to it (which it still is able to detect/decode).

    Note that I care nothing about power consumption.  I want to detect/decode all of the advertisement packets of my reference transmitter.  I don't care if it uses more power.  I don't want to miss a single transmission.

Related