This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5430 SPI sample code

Hi, 

I tried to run the code which was used by another forum user: 

https://devzone.nordicsemi.com/f/nordic-q-a/63149/nrf5340---p0-10-not-working-as-spim-miso-on-non-secure-build/257673#257673

I used zip file "spi-rallare-secure-working.zip". 

The first issue that occurred was that some of the variables were not user-configurable (CONFIG_UART_0_NRF_UARTE,CONFIG_SPI_1_NRF_SPIM,CONFIG_SPI_2_NRF_SPIM) 

After commenting those variables (and changing k_sleep(1000) to k_sleep(K_SECONDS(1)); - I also tried k_sleep(K_SECONDS(1));)

I got this:

My board is not able to initialize SPI_1. 

When it comes to wiring I just connect MISO(P0.10) and MOSI(P0.4). 

What can be wrong with my sample code?

Thanks, 

Marta

Parents Reply Children
  • Hi Marta, 

    I'm truly sorry for this to have taken so long. Attached is a working version on the secure SPI sample: spi-rallare-secure-working-NCS130.zip

    First off all the overlay files were wrong, I completely missed that:

    1. The name of the overlay was wrong. The overlay file should be named: nrf5340pdk_nrf5340_cpuapp.overlay (the same goes for non-secure)
    2. The status field should "okay" and not "ok". See below

    &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	mosi-pin = <4>;
    	miso-pin = <10>;	//<5>;
    	sck-pin = <6>;
    };
    
    &spi2 {
    	status = "disabled";
    };
    
    &i2c1 {
        status = "disabled";
    };
    

    The issue with board overlay file name will cause the compilation to not set correct SPI_1 configuration, leading to it not finding SPI_1 and giving the error "Could not get SPI_1 device".  Adding CONFING_RESET_ON_FATAL_ERROR=n will stop the device from going into boot loop.

    Here is the current project configuration I used: 

    CONFIG_SERIAL=y
    
    CONFIG_UART_INTERRUPT_DRIVEN=y
    
    CONFIG_LOG=y
    CONFIG_LOG_IMMEDIATE=y
    
    # SPI
    CONFIG_SPI=y
    CONFIG_SPI_1=y
    
    CONFIG_MAIN_STACK_SIZE=4096
    
    CONFIG_RESET_ON_FATAL_ERROR=n

    Let me know how it works for you!

    Kind regards,
    Øyvind

  • Hi Øyvind,

    Sorry for slow response.

    It works like a charm now! Thank you very much for your support :)

    Best,

    Marta

  • You are welcome, Marta! Slight smile If you don't have any further questions, I will close this ticket.

    Have a great day!

    Kind regards,
    Øyvind

Related