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

problems with SPI on nRF9160 and Zephyr

I am trying to develop a SPI interface to a CANBUS controller for the nRF9160 for the zephyr platform.

The issue I am having at this point is is that I am unable to see any activity on the SPI lines from the nRF9160. 

My first test of the SPI is to connect to an FLASH EEPROM that I have jjust to test the SPI connectivity. 

for now I am running without secure_boot and the cellular connection as it simplified testing with the uart.

I have added the lines 

&spi2 {
status = "ok";
sck-pin = <26>;
mosi-pin = <27>;
miso-pin = <28>;
spi-max-frequency = <4000000>;
}; 

to the nrf9160_pca10090.overlay file and 

# General config
CONFIG_NEWLIB_LIBC=y


CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_GPIO=y

CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_2=y
CONFIG_SPI_2_NRF_SPIM=y

CONFIG_PRINTK=y
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=y

is my prj.conf file

I do get a device back when I device_get_binding("SPI_2").

I have copied and modified some SPI code from the Zephyr samples.  but have not been able to get any response from the SPI pins.

Do you have any SPI samples specifically for the nRF9160

Parents
  • Hi Jeff,

    When working with nrf9160 samples, it has to be built as a non-secure firmware image.
    So that means that you need to add:

    CONFIG_TRUSTED_EXECUTION_NONSECURE=y

    in the prj.conf file for your application. I also recommend that you copy your .overlay file and add it in the secure_boot sample and build/flash that again.

    (I assume that you are already using the nrfx_spi driver)

    We do not have a sample for this yet, but I can see if I can make something for you if the pointers aren't enough.

  • Martin

    I tried setting the project up on SPI 3 and configuring secure boot.

    the prj.conf for secure boot

    CONFIG_TRUSTED_EXECUTION_SECURE=y
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_SPI_3_NRF_SPIM=y
    # needed to get the NRF_UARTE2 define
    CONFIG_UART_2_NRF_UARTE=y
    

    the overlay for secure boot

    /* needed to get the NRF_UARTE2 defined */
    &uart1{
    	current-speed = <38400>;
    	tx-pin = <24>;
    	rx-pin = <25>;
    	cts-pin = <27>;
    	rts-pin = <28>;
    
    };
    
    &uart2 {
    	current-speed = <1000000>;
    	status = "ok";
    	tx-pin = <18>;
    	rx-pin = <17>;
    	rts-pin = <19>;
    	cts-pin = <21>;
    };
    
    &spi3 {
            status = "ok";
            sck-pin = <26>;
            mosi-pin = <27>;
            miso-pin = <28>;
            spi-max-frequency = <4000000>;
    };

    the prj.conf file for the application

    # General config
    CONFIG_NEWLIB_LIBC=y
    
    # Trusted execution
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    
    
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    
    CONFIG_GPIO=y
    
    CONFIG_SPI=y
    CONFIG_SPI_NRFX=y
    CONFIG_SPI_3=y
    CONFIG_SPI_3_NRF_SPIM=y
    
    CONFIG_PRINTK=y
    CONFIG_HEAP_MEM_POOL_SIZE=256
    CONFIG_ASSERT=y

    the overlay for the application

    &spi3 {
            status = "ok";
            sck-pin = <26>;
            mosi-pin = <27>;
            miso-pin = <28>;
            spi-max-frequency = <4000000>;
    };

    I am still not seeing any activity on the SPI clock pin

    I will try your next suggestion

    Thanks for the Help 

Reply
  • Martin

    I tried setting the project up on SPI 3 and configuring secure boot.

    the prj.conf for secure boot

    CONFIG_TRUSTED_EXECUTION_SECURE=y
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_SPI_3_NRF_SPIM=y
    # needed to get the NRF_UARTE2 define
    CONFIG_UART_2_NRF_UARTE=y
    

    the overlay for secure boot

    /* needed to get the NRF_UARTE2 defined */
    &uart1{
    	current-speed = <38400>;
    	tx-pin = <24>;
    	rx-pin = <25>;
    	cts-pin = <27>;
    	rts-pin = <28>;
    
    };
    
    &uart2 {
    	current-speed = <1000000>;
    	status = "ok";
    	tx-pin = <18>;
    	rx-pin = <17>;
    	rts-pin = <19>;
    	cts-pin = <21>;
    };
    
    &spi3 {
            status = "ok";
            sck-pin = <26>;
            mosi-pin = <27>;
            miso-pin = <28>;
            spi-max-frequency = <4000000>;
    };

    the prj.conf file for the application

    # General config
    CONFIG_NEWLIB_LIBC=y
    
    # Trusted execution
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    
    
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    
    CONFIG_GPIO=y
    
    CONFIG_SPI=y
    CONFIG_SPI_NRFX=y
    CONFIG_SPI_3=y
    CONFIG_SPI_3_NRF_SPIM=y
    
    CONFIG_PRINTK=y
    CONFIG_HEAP_MEM_POOL_SIZE=256
    CONFIG_ASSERT=y

    the overlay for the application

    &spi3 {
            status = "ok";
            sck-pin = <26>;
            mosi-pin = <27>;
            miso-pin = <28>;
            spi-max-frequency = <4000000>;
    };

    I am still not seeing any activity on the SPI clock pin

    I will try your next suggestion

    Thanks for the Help 

Children
No Data
Related