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?

Parents
  • 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";

Reply
  • 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";

Children
Related