This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

the SPI Lookback example running on nrf5340dk and nrf52840dk output different as expected

Hi all,

when I follow the blog as below, find the actual output is not same as expected.

Adding a Peripheral to an NCS Zephyr project - Peripherals And RF Test - nRF Connect SDK guides - Nordic DevZone (nordicsemi.com)

The output what I got as following:

 

Expected Initial Output can be seen from: https://github.com/ThatByDesign/Nordic-Examples/tree/main/spi_loopback

which is as following:

there are three problem when I test on nrf5340dk and 53840dk:

  1. SPIM RX outputs are unreadable words.
  2. Can not get SPIS RX output.
  3.  Have to comment out uart0 in board overlay file or no output at all.

how to fix the problem #1 and #2 above, and what is the reason of number #3?

I want to pass this test before I integrate a SPI peripheral to nrf5340 SoC. I am appreciate get your help.

I use nRF Connect SDK 1.7.0 on windows test this example.

  • Hi,

    It seems like there might be some adjustments to do with nRF53 as that blog is written for nRF52. I have not tested it myself, but can do it tomorrow to see if i find some differences that needs to be adjusted in configuration.

  • Hi,

    I did not run this steps from the blogpost, but a closer look to your logs show that you are using pin numbers 22,23,24 and 25 on nRF5340 DK (same numbers as shown in the github example for nRF52 DK).

    But note that on nRF5340 DK (assigned pins for buttons and Leds) Section 4.7 Buttons and LEDs that gpio pin 23 and 24 are used for buttons and cannot be used for SPI in your example. Please used some unassigned pin numbers for SPI. You will see all pre assigned pin numbers at the back of your DK.

  • finally it works after I changed the pin used and the project configuration.

    the board overlay file changed as below:

    &spi1 {
    	compatible = "nordic,nrf-spis";
    	status = "okay";
    	sck-pin = <41>;
    	mosi-pin = <40>;
    	miso-pin = <39>;
    	csn-pin = <38>;
    	
    	def-char = <0xC3>;
    };
    
    &spi2 { 
    	compatible = "nordic,nrf-spim"; 
    	status = "okay";
    	sck-pin = <4>;
    	mosi-pin = <5>;
    	miso-pin = <6>;
    
    	cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
    };
    

    the prj.conf file changed as below:

    #
    # Copyright (c) 2020 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    
    CONFIG_SPI=y
    
    # CONFIG_SPI_1=y
    CONFIG_SPI_SLAVE=y
    # CONFIG_SPI_1_OP_MODES=2
    
    # CONFIG_SPI_2=y
    # CONFIG_SPI_2_OP_MODES=1
    # CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58=y
    
    # CONFIG_USE_SEGGER_RTT=y
    # CONFIG_RTT_CONSOLE=y
    # CONFIG_UART_CONSOLE=n

Related