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