Unable to enable gain control on nRF21540 FEM with nRF5340

Hello,

I’m trying to get an nRF21540 FEM working with a chip-down nRF5340 design under NCS v2.4.2. I’m able to enable the FEM at its default gain setting, but I hit a wall trying to get gain control either via the mode-gpios property and associated KConfig settings, or dynamic control via SPI0 on the network core.

I have a pin forwarder defined in the application core's DTS:

gpio_fwd: nrf-gpio-forwarder {
        compatible = "nordic,nrf-gpio-forwarder";
		status = "okay";
		nrf21540-gpio-if {
			gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>, /* rx-en-gpios */
					<&gpio1 6 GPIO_ACTIVE_HIGH>, /* tx-en-gpios */
					<&gpio0 29 GPIO_ACTIVE_HIGH>, /* pdn-gpios */
					<&gpio1 8 GPIO_ACTIVE_HIGH>;
		};
		nrf21540-spi-if {
			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>, /* clk */
					<&gpio0 27 GPIO_ACTIVE_HIGH>, /* mosi */
					<&gpio0 24 GPIO_ACTIVE_HIGH>, /* csn */
					<&gpio0 26 GPIO_ACTIVE_HIGH>; /* miso */
		};	
    };
 

Here's my hci_rpmsg.overlay:

/ {
   nrf_radio_fem: nrf21540_fem {
		compatible  = "nordic,nrf21540-fem";
		tx-en-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
		rx-en-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
		pdn-gpios   = <&gpio0 29 GPIO_ACTIVE_HIGH>;
		// mode-gpios  = <&gpio1 8 GPIO_ACTIVE_HIGH>;
		spi-if = <&nrf_radio_fem_spi>;
		supply-voltage-mv = <1800>;
  	};
};

&radio {
	fem = <&nrf_radio_fem>;
};

&uart0 {
   status = "disabled";
};

fem_spi: &spi0 {
	status = "okay";
	pinctrl-0 = <&spi0_default_alt>;
	pinctrl-1 = <&spi0_sleep_alt>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;

	nrf_radio_fem_spi: nrf21540_fem_spi@0 {
		compatible = "nordic,nrf21540-fem-spi";
		status = "okay";
		reg = <0>;
		spi-max-frequency = <8000000>;
	};
};

&pinctrl {

	spi0_default_alt: spi0_default_alt {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK,  0, 28)>,
					<NRF_PSEL(SPIM_MISO, 0, 26)>,
					<NRF_PSEL(SPIM_MOSI, 0, 27)>;
		};
	};
	spi0_sleep_alt: spi0_sleep_alt {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK,  0, 28)>,
					<NRF_PSEL(SPIM_MISO, 0, 26)>,
					<NRF_PSEL(SPIM_MOSI, 0, 27)>;
			low-power-enable;
		};
	};
};

And here's the relevant settings from my hci_rpmsg.conf:

CONFIG_FEM=y
CONFIG_FEM_AL_LIB=y
CONFIG_MPSL_FEM=y
CONFIG_MPSL_FEM_ONLY=y

CONFIG_GPIO=y
CONFIG_MPSL_FEM_NRF21540_GPIO=y

# CONFIG_SPI=y
# CONFIG_SPI_NRFX=y
# CONFIG_NRFX_SPIM0=y
# CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
# CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y

CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTA=20
CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB_POUTB=10
CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=20

It builds successfully and has a much higher RSSI than with the FEM configs disabled, as expected.

When I uncomment the nrf_radio_fem's mode-gpios definition to allow switching between 10dB and 20dB, I get an undeclared device error originating from:

/opt/nordic/ncs/v2.4.2/nrf/subsys/mpsl/fem/nrf21540_gpio/mpsl_fem_nrf21540_gpio.c:174:25: note: in expansion of macro 'DEVICE_DT_GET'
174 | DEVICE_DT_GET(MPSL_FEM_GPIO_PORT(mode_gpios)),

And when I uncomment the SPI-related configs, I get another undeclared device error originating from:

/opt/nordic/ncs/v2.4.2/zephyr/drivers/spi/spi_nrfx_spim.c:625:1: note: in expansion of macro 'SPI_NRFX_SPIM_DEFINE'
625 | SPI_NRFX_SPIM_DEFINE(0);

In my experience, these types of error are usually due to some missing KConfig flag, but I'm all out of guesses as to which I may be missing that's not covered in the official docs. Or am I missing something else?

Thanks

Parents
  • Hi

    What Direction Finding features exactly is it you're using? Note that Direction Finding or the Distance Measurement toolbox won't be possible to implement when using a FEM since the antenna switching and synchronization is too timing critical for a FEM to be used.

    Best regards,

    Simon

  • For context, this is for a beacon that's integrating with a third-party AoA locator. We are not using Nordic's Distance Measurement Toolbox, nor using AoD so there's no antenna switching on the beacon.

    Our last revision of the beacon used the Skyworks SKY66405-11 that's packaged with the UBlox Nora B126, and after some help from Nordic were able to get the FEM working in our direction finding application.

    The specific config flags we need that require the Zephyr BLE controller (CONFIG_BT_LL_SW_SPLIT=y) are these:

    CONFIG_BT_CTLR_ADVANCED_FEATURES=y
    CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y
    CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX=16
Reply
  • For context, this is for a beacon that's integrating with a third-party AoA locator. We are not using Nordic's Distance Measurement Toolbox, nor using AoD so there's no antenna switching on the beacon.

    Our last revision of the beacon used the Skyworks SKY66405-11 that's packaged with the UBlox Nora B126, and after some help from Nordic were able to get the FEM working in our direction finding application.

    The specific config flags we need that require the Zephyr BLE controller (CONFIG_BT_LL_SW_SPLIT=y) are these:

    CONFIG_BT_CTLR_ADVANCED_FEATURES=y
    CONFIG_BT_CTLR_ADV_SYNC_PDU_BACK2BACK=y
    CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX=16
Children
No Data
Related