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
Parents
  • Hi Sheldon,

    You only need to specify the FEM in the device tree (as I see you are doing) and enable MPSL FEM support in your project configuration. Then the MPSL will automatically control the FEM. You can read more about this under Working with RF front-end modules.

    Einar

  • I tried to enable it in the pro.config: 

    CONFIG_MPSL_FEM =y
    The problem is I get an error:
    c:/ncs/bt-fund-main/lesson4/blefund_less4_exer3_solution/prj.conf:24: warning: attempt to assign the value 'y' to the undefined symbol MPSL_FEM

    error: Aborting due to Kconfig warnings
    The auto complete suggested use of the CONFIG_MPSL_FEM so I thought for sure it would work.  I'm not sure why it thinks it is undefined.
  • 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.

  • Hi,

    As you see the control poins toggling on the scope the control mechanism seems to be good, and so I would be very interested in looking at the HW as the next step.

    Sheldon01 said:
    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.

    I see. In that case you can try to set for instance the TN_EN externally and see if that makes a difference on the Tx power. Note that you will not loose any transmissions by letting the MPSL control this. By controlling the FEM, it will enable the PA and LNA as needed, and there should not be any down sides with this approach.

  • As an experiment, I redefined the location of the '&nRF_radio_fem rx-en' pin to an unused location.  The RSSI that I then measured was much much weaker.  Thus, I think the signals are probably being switched ok but there is a hardware problem.  Is there a way that I can confidentially have someone at Nordic look at my design (not letting it be shown to the public where our competition could see it)?

  • Alas, I've really not looked at the hardware layout much (until now) and I can clearly see something that is very different than the development board.  My boards were made incorrectly!  I'm sorry that I have wasted your time looking at the software aspect of the possibilities.  Clearly something is wrong with my hardware!

  • Hi,

    I see, that makes sense. You can make a new private ticket and request a review of your board. Please upload both your schematic and layout in form of gerber files in the private case, and write that you see low output power.

Reply Children
Related