How to make nRF21540 on Thingy53 working

Hi community,

I have a similar custom board as Thingy53, which has the nrf21540 module on board.

my purpose is to turn on the nrf21540 and do the reconnection, when the connection via normal way is lost. 

these are the meaningful rescources I can find, but still cannot make the nrf21540 on my board working.

Developing with the nRF21540 EK

(+) nRF21540 is not compatible with nRF54L15 - Nordic Q&A - Nordic DevZone - Nordic DevZone

(+) Thingy 53 and nRF21540 Frontend (Bluetooth Mesh) - How to set TX power via SPI - Nordic Q&A - Nordic DevZone - Nordic DevZone

my configuration is just copied from the thingy53:

in the dts file for cpuapp:

    gpio_fwd: nrf-gpio-forwarder {
        compatible = "nordic,nrf-gpio-forwarder";
        status = "disabled";
        fem-gpio-if {
            gpios = <&gpio1 9 0>,
                <&gpio1 5 0>,
                <&gpio0 27 0>,
                <&gpio0 25 0>;
        };
    };

    /* Disabled by default as SPI lines are shared with peripherals on application core */
    spi_fwd: nrf-spi-forwarder {
        compatible = "nordic,nrf-gpio-forwarder";
        status = "disabled";
        fem-spi-if {
            gpios = <&gpio1 8 0>,
                <&gpio0 26 0>,
                <&gpio0 24 0>,
                <&gpio1 7 0>;
        };
although don't understand why it's needed?
in the dts file for cpunet:
	nrf_radio_fem: fem {
		compatible = "nordic,nrf21540-fem";
		rx-en-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
		mode-gpios  = <&gpio1 5 GPIO_ACTIVE_HIGH>;
		pdn-gpios   = <&gpio0 27 GPIO_ACTIVE_HIGH>;
		tx-en-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
		spi-if = <&nrf_radio_fem_spi>;
		supply-voltage-mv = <3000>;
	};
};

/* Disabled by default as shares same GPIO lines as SPI peripherals on application core */
fem_spi: &spi0 {
	status = "okay";
	cs-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;

	pinctrl-0 = <&spi0_default>;
	pinctrl-1 = <&spi0_sleep>;
	pinctrl-names = "default", "sleep";
	nrf_radio_fem_spi: nrf21540_fem_spi@0 {
		compatible = "nordic,nrf21540-fem-spi";
		status = "okay";
		reg = <0>;
		spi-max-frequency = <8000000>;
	};
};

&radio {
	/* Uncomment to enable SPI interface for FEM */
	fem = <&nrf_radio_fem>;
};
then I added these lines in the ipc_radio.conf:
CONFIG_MPSL=y
CONFIG_MPSL_FEM=y
CONFIG_MPSL_FEM_NRF21540_GPIO=y

CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
CONFIG_MPSL_FEM_NRF21540_TX_GAIN_DB=20
CONFIG_MPSL_FEM_NRF21540_RX_GAIN_DB=13
CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y
CONFIG_BT_CTLR_TX_PWR_ANTENNA=20
then build and flash, can't see any RSSI change, the nrf21540 module is not enabled.
How these config command work in the background? does the nrf21540 communicate with the appcore or netcore?
any example code for thingy53? do I have to pull up the PDN pin of nrf21540 manually to turn on the chip? 
Regards
Danny
Parents Reply Children
  • Hi  

    thanks!

    after enabling both "status" for gpio_fwd and spi_fwd, the nRF21540 module is working.

    ***************************************************************************************************

    my purpose is to dynamically switch the short and long range antenna depending on the bluetooth signal strength, is it possible to achivce this?

    or at least, first turn on the short range antenna, if it's disconnected, then turn on the long range antenna by pulling up the PDN pin of nRF21540.

    Now the questions are:

    1. Since the GPIOs and SPI bus are configured in both dts files for cpuapp and cpunet, somehow they are forwarded from cpuapp to cpunet, how shall I dynamically pull up/down the PDN pin? in which core shall I run this code for controlling the GPIO?

    2. After switching from long range antenna to short range antenna, PDN=0, shall the SPI bus for FEM be disabled? otherwise the data still goes to FEM?

    Regards

    Danny

Related