SPI example overlay file has 4 problems

Hi,

I test async SPI example with NCS v2.3.0 and nRF52-DK.

https://github.com/too1/ncs-spi-master-slave-example

the nrf52dk_nrf52832.overlay show 4 problems.

&pinctrl {
	spi_master_default: spi_master_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
					<NRF_PSEL(SPIM_MOSI, 0, 30)>,
					<NRF_PSEL(SPIM_MISO, 0, 29)>;
		};
	};

	spi_master_sleep: spi_master_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
					<NRF_PSEL(SPIM_MOSI, 0, 30)>,
					<NRF_PSEL(SPIM_MISO, 0, 29)>;
			low-power-enable;
		};
	};

	spi_slave_default: spi_slave_default {
		group1 {
			psels = <NRF_PSEL(SPIS_SCK, 0, 11)>,
					<NRF_PSEL(SPIS_MOSI, 0, 12)>,
					<NRF_PSEL(SPIS_MISO, 0, 13)>,
					<NRF_PSEL(SPIS_CSN, 0, 14)>;
		};
	};

	spi_slave_sleep: spi_slave_sleep {
		group1 {
			psels = <NRF_PSEL(SPIS_SCK, 0, 11)>,
					<NRF_PSEL(SPIS_MOSI, 0, 12)>,
					<NRF_PSEL(SPIS_MISO, 0, 13)>,
					<NRF_PSEL(SPIS_CSN, 0, 14)>;
			low-power-enable;
		};
	};
};

my_spi_master: &spi1 {
	compatible = "nordic,nrf-spi";
	status = "okay";
	pinctrl-0 = <&spi_master_default>;
	pinctrl-1 = <&spi_master_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
	reg_my_spi_master: spi-dev-a@0 {
		reg = <0>;
	};
};

my_spi_slave: &spi2 {
	compatible = "nordic,nrf-spis";
	status = "okay";
	pinctrl-0 = <&spi_slave_default>;
	pinctrl-1 = <&spi_slave_sleep>;
	pinctrl-names = "default", "sleep";
	def-char = <0x00>;
};

I test the pins with showPins() function taken from this ticket,

 Control E-Paper display with SPI. 

the pins map is as the following,

P0.00 Map: RTC-OSC-IN
P0.01 Map: RTC-OSC-OUT
P0.02 Map: -
P0.03 Map: -
P0.04 Map: -
P0.05 Map: UartE0 RTS
P0.06 Map: UartE0 Tx
P0.07 Map: UartE0 CTS
P0.08 Map: UartE0 Rx
P0.09 Map: -
P0.10 Map: -
P0.11 Map: SPI2 SCK
P0.12 Map: SPI2 MISO
P0.13 Map: SPI2 MOSI
P0.14 Map: -
P0.15 Map: -
P0.16 Map: -
P0.17 Map: -
P0.18 Map: -
P0.19 Map: -
P0.20 Map: -
P0.21 Map: nRESET
P0.22 Map: NFC 1
P0.23 Map: NFC 2
P0.24 Map: -
P0.25 Map: -
P0.26 Map: -
P0.27 Map: -
P0.28 Map: -
P0.29 Map: SPI1 MISO
P0.30 Map: SP-TWI1 SDA
P0.31 Map: SP-TWI1 SCL

It is not correct in the P0.30, P0.31 and P0.12, P0.13 are swapped.

Does the overlay file problems need to fix, or the overlay file problems can be ignored?

  • Hi,

    Can you share the complete build log? It should be in the 'Terminal' tab in the panel:

    Please make sure to do a pristine build so you will get the complete build log.

    Best regards,
    Marte

  • Hi  ,

    I changed spi_transceive_async() to spi_transceive_signal() in main.c to avoid the warning, the other code is the same.

    The build log is as the following:

     *  Executing task: nRF Connect: Build [pristine]: ncs-spi-master-slave-example-master/build (active) 
    
    Building ncs-spi-master-slave-example-master
    west build --build-dir c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master --pristine --board nrf52dk_nrf52832 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=c:/ncs_example_test/coprocessor;c:/ncs_example_test/light_bulb;c:/ncs_example_test/lock -DCONF_FILE=c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/prj.conf -DDTC_OVERLAY_FILE=c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/nrf52dk_nrf52832.overlay
    
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master
    -- Found Python3: C:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Cache files will be written to: C:/ncs/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52dk_nrf52832
    -- Found host-tools: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
    -- Found BOARD.dts: C:/ncs/v2.3.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts
    -- Found devicetree overlay: c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/nrf52dk_nrf52832.overlay
    -- Generated zephyr.dts: C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build/zephyr/dts.cmake
    
    warning: Experimental symbol SPI_SLAVE is enabled.
    
    Parsing C:/ncs/v2.3.0/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.3.0/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration 'c:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/prj.conf'
    Configuration saved to 'C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build/zephyr/.config'
    Kconfig header saved to 'C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/Felix/Desktop/ncs-spi-master-slave-example-master/build
    -- west build: building application
    [1/175] Generating include/generated/version.h
    -- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr), build: v3.2.99-ncs2
    [165/175] Linking C executable zephyr\zephyr_pre0.elf
    
    [169/175] Linking C executable zephyr\zephyr_pre1.elf
    
    [175/175] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       37496 B       512 KB      7.15%
                 RAM:        9536 B        64 KB     14.55%
            IDT_LIST:          0 GB         2 KB      0.00%
     *  Terminal will be reused by tasks, press any key to close it. 
    

  • Hi,

    I do not see any errors or anything in the build log that should cause issues, so it should be fine.

    Best regards,
    Marte

  • SP-TWI1 SDA means both SPI1 MOSI and TWI1 SDA as the two peripherals SPI1 and TWI1 are the same hardware which can be used in either mode but not both modes together, ditto SP-TWI SCL. This test shows when they are not (eg on an nRF52811)

    /*
     * Table 20: Peripherals sharing an ID on nRF53832
     *  ==============================================
     *  Instance
     *  ID  3 (0x40003000) SPIM SPIS SPI TWIM TWIS TWI
     *  ID  4 (0x40004000) SPIM SPIS SPI TWIM TWIS TWI
     *  ID 35 (0x40023000) SPIM SPIS SPI
     */
    STATIC_ASSERT ((uint32_t)NRF_TWIM0 == (uint32_t)NRF_SPI0, "Error: NRF_TWIM0 differs from NRF_SPI0");
    STATIC_ASSERT ((uint32_t)NRF_TWIM1 == (uint32_t)NRF_SPI1, "Error: NRF_TWIM1 differs from NRF_SPI1");

    // Extend description
        if (NRF_TWIM1->PSEL.SCL  == PinId) return "SPI1 SCK or TWI1 SCL";
        if (NRF_TWIM1->PSEL.SDA  == PinId) return "SPI1 MOSI or TWI1 SDA";
        // or just put this one first before the TWIM1 test
        if (NRF_SPI1->PSEL.SCK  == PinId) return "SPI1 SCK";
        if (NRF_SPI1->PSEL.MOSI == PinId) return "SPI1 MOSI";

    However pins P0.12 and P0.13 do look as though they are swapped.

        if (NRF_SPI2->PSEL.SCK  == PinId) return "SPI2 SCK";
        if (NRF_SPI2->PSEL.MOSI == PinId) return "SPI2 MOSI";
        if (NRF_SPI2->PSEL.MISO == PinId) return "SPI2 MISO";

  • Hi  ,

    Thanks for your showPins() function.

    The P0.12 and P0.13 are used for SPIS, so the names are swapped because their name are based on SPIM.

    SPIM:

    SPIS:

    VS code also show the correct pin usages.

    The overlay file problem messages seems can be ignored if the project build is successfully, although I do not know what is the root cause for overlay file problems.

Related