nrf5340_audio" in "v2.8.0" supports "GAIN control" in "SPI+GPIO mode".

Please confirm whether the "sample app nrf5340_audio" in "v2.8.0" supports "GAIN control" in "SPI+GPIO mode".
the method to enable "GAIN control" in "SPI+GPIO mode" if the sample app "nrf5340_audio" in v2.8.0 supports it.


https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/device_guides/fem/fem_nrf21540_gpio_spi.html
I tried to enable GAIN control in GPIO+SPI mode according to the method described in [reference/link], but I failed.

  • Hi, 

    You can enable enable GAIN control and GPIO+SPI mode in the nrf/applications/nrf5340_audio/sysbuild/ipc_radio/prj.conf

    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y

    Then, refer to the west command in the Adding FEM support section to build. 

    Check:
    the .config file under build/ipc_radio/zephyr:

    The zephyr.dts file under build/ipc_radio/zephyr

    Regards,
    Amanda H.

  • Thank you for your help.

    but enabled GPIO+SPI mode GAIN control based on the procedure you provided, but it did not work as expected. The setting values I tried are listed below, so please check them.

    1.ncs\v2.8.0\nrf\boards\shields\nrf21540ek\nrf21540ek_fwd.overlay
     &gpio_fwd {
        nrf21540-gpio-if {
            gpios = <&gpio0 3 0>,   /* tx-en-gpios */
                <&gpio0 13 0>,      /* rx-en-gpios */
                <&gpio0 23 0>;      /* pdn-gpios */    
                <&gpio0 23 0>,      /* ant-sel-gpios */    
                <&gpio0 23 0>;      /* mode-gpios */
        };
        nrf21540-spi-if {
            gpios = <&gpio1 9 0>,       /* cs-gpios */
                <&gpio1 7 0>,       /* SPIM_SCK */
                <&gpio0 21 0>,      /* SPIM_MISO */
                <&gpio1 5 0>;       /* SPIM_MOSI */
        };
    };

    2.ncs\v2.8.0\nrf\boards\shields\nrf21540ek\nrf21540ek.overlay
    / {
        nrf_radio_fem: nrf21540_fem {
            compatible = "nordic,nrf21540-fem";
            tx-en-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;   /* D5 */
            rx-en-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;    /* D3 */
            pdn-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;     /* D9 */
            ant-sel-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; /* D4 */
            mode-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;     /* D2 */
            spi-if = <&nrf_radio_fem_spi>;
            supply-voltage-mv = <3000>;
        };
    };

    fem_spi: &arduino_spi {
        status = "okay";
        cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; /* D10 */

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

    3.ncs\v2.8.0\zephyr\boards\nordic\nrf5340_audio_dk\nrf5340_audio_dk_nrf5340_cpunet-pinctrl.dtsi
        spi0_default: spi0_default {
            group1 {
                psels = <NRF_PSEL(SPIM_SCK, 1, 7)>,
                    <NRF_PSEL(SPIM_MISO, 0, 21)>,
                    <NRF_PSEL(SPIM_MOSI, 1, 5)>;
            };
        };

        spi0_sleep: spi0_sleep {
            group1 {
                psels = <NRF_PSEL(SPIM_SCK, 1, 7)>,
                    <NRF_PSEL(SPIM_MISO, 0, 21)>,
                    <NRF_PSEL(SPIM_MOSI, 1, 5)>;
                low-power-enable;
            };
        };


    4.ncs\v2.8.0\zephyr\boards\nordic\nrf5340_audio_dk\nrf5340_audio_dk_nrf5340_cpunet.dts,uart0
    &uart0 {
        status = "disabled";
    };

    5.ncs\v2.8.0\zephyr\boards\nordic\nrf5340_audio_dk\nrf5340_audio_dk_nrf5340_cpuapp_common-pinctrl.dtsi
        spi4_default: spi4_default {
            group1 {

                psels = <NRF_PSEL(SPIM_SCK, 1, 7)>,
                    <NRF_PSEL(SPIM_MISO, 0, 21)>,
                    <NRF_PSEL(SPIM_MOSI, 1, 5)>;
            };
        };

        spi4_sleep: spi4_sleep {
            group1 {

                psels = <NRF_PSEL(SPIM_SCK, 1, 7)>,
                    <NRF_PSEL(SPIM_MISO, 0, 21)>,
                    <NRF_PSEL(SPIM_MOSI, 1, 5)>;
                low-power-enable;
            };
        };

    6.ncs\v2.8.0\zephyr\boards\nordic\nrf5340_audio_dk\nrf5340_audio_dk_nrf5340_cpuapp_common.dtsi
    arduino_spi: &spi4 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi4_default>;
        pinctrl-1 = <&spi4_sleep>;
        pinctrl-names = "default", "sleep";
        reg_pa_spi_master:  spi-dev-a@0 {
            reg = <0>;
        };  
    };

    7.ncsv2.8.0\nrf\applications\nrf5340_audio\sysbuild\ipc_radio\prj.conf
    CONFIG_MPSL_FEM_NRF21540_GPIO_SPI=y
    CONFIG_MPSL_FEM_NRF21540_RUNTIME_PA_GAIN_CONTROL=y

    -----------------------------------------------------------
    The result of the execution is as follows:
    -- [00:00:00.004,272] <inf> pa_ctrl: PA start 0x18 dB
    -- [00:00:01.007,141] <err> bt_hci_driver: Endpoint binding failed with -11
    -- [00:00:01.007,141] <err> bt_hci_core: HCI driver open failed (-11)
    -- [00:00:01.007,141] <err> main: ERR_CHK Err_code: [-11] @ line: 369
    -- [00:00:01.007,141] <err> os: r0/a1: 0x00000003 r1/a2: 0x00000003 r2/a3: 0x00000002
    -- [00:00:01.007,171] <err> os: r3/a4: 0x00000003 r12/ip: 0x00000000 r14/lr: 0x00003829
    -- [00:00:01.007,171] <err> os: xpsr: 0x09100000
    -- [00:00:01.007,171] <err> os: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x50842500 s[ 3]: 0x00000001
    -- [00:00:01.007,171] <err> os: s[ 4]: 0x00052ab0 s[ 5]: 0x00000171 s[ 6]: 0xfffffff5 s[ 7]: 0x000530f8
    -- [00:00:01.007,171] <err> os: s[ 8]: 0x200051d8 s[ 9]: 0xffffffff s[10]: 0x20002860 s[11]: 0x00000000
    -- [00:00:01.007,202] <err> os: s[12]: 0x00052814 s[13]: 0x2001a228 s[14]: 0x00041121 s[15]: 0x00012e23
    -- [00:00:01.007,202] <err> os: fpscr: 0x00000000
    -- [00:00:01.007,202] <err> os: Faulting instruction address (r15/pc): 0x00003838
    -- [00:00:01.007,232] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
    -- [00:00:01.007,232] <err> os: Current thread: 0x200050d0 (main)
    -- [00:00:01.007,232] <err> error_handler: Caught system error -- reason 3. Cold rebooting.

    #bt_ipc_open failed.

  • Hi, 

    The team confirmed that AudioDK cannot support nRF21540-EK in "SPI+GPIO mode" because the SPI on AudioDK is for codec and Netcore cannot use it. Therefore, netcore would get the crash. Please use the GPIO mode for nRF21540-EK. 

    -Amanda H. 

  • Thank you for your response.

    I would like to use the PowerAmp module.

    As a countermeasure, I commented out the CODEC's SPI-related settings and attempted GAIN control in "SPI+GPIO mode."

    As a result, the HCI device's Open processing (bt_hci_open) was successful.

    However, it seems that the SPI communication (settings) in the PowerAmp startup sequence is failing.

    Is PowerAmp's SPI controlled by the network core?

    Is there any way to perform PowerAmp's SPI on the application core side?

    Another plan I'm considering is to perform GAIN control in "GPIO mode."

    In that case, is it possible for the application side to control the SPI for communication with the nrf21540, and for the network core to control the tx-en/rx-en-gpio?

  • If you are using the nRF21540 then both the pins and the SPI have to be controlled from the Network core due to timing constraints.

Related