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

Simple SPI

Hello,

I am using nrf9160 and want to test the just simple SPI function. The code that I found from github(https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi c) is old and gives me too many errors. Are there any simple SPI code that I can try in my nrf9160 board in order to test whether I can send a simple data via SPI. I also found spi_flash_at45 however I don't have any device from at45 family to test it so another simple example would be so helpful for me. 

Thank you

Parents
  • Hi,

     

    Generic test code for nRF5340 can be found here:

    https://devzone.nordicsemi.com/f/nordic-q-a/67065/how-to-configure-and-setup-an-spi-device-to-nrf5340/276687

     

    I added some small modifications to the above sample, as SPI0 is shared with UART0/TWIM0 etc on nRF9160:

    4520.simple_spi_test_nrf9160.zip

     

    Kind regards,

    Håkon

  • Hi,

    Thank you for the fast reply. I just ran the code however I am always receiving 0 in the RX_recv. Shouldn't the value in RX_recv be similar with TX_sent since this code is just tries to send a value and receive it back as far as I understood? I didn't make any change in the code yet.

    Q2:

    I want to send data from nrf9160 to an external device, in order to just make a simple test before implementing a flash driver, I want to test the pins and spi, for that I am using scana to check the signals coming from spi ports. My question here is that how can I send my data to scana rather than making a loopback. For instance first I have to ad a chip select for scana, adding ss=<13> to the overlay file can be the first step right? What should I change other than this?

    Thank you

  • Hi,

     

    verulia said:
    Thank you for the fast reply. I just ran the code however I am always receiving 0 in the RX_recv. Shouldn't the value in RX_recv be similar with TX_sent since this code is just tries to send a value and receive it back as far as I understood? I didn't make any change in the code yet.

    If you connect MISO and MOSI together, then you will receive what you send. 

     

    verulia said:
    I want to send data from nrf9160 to an external device, in order to just make a simple test before implementing a flash driver, I want to test the pins and spi, for that I am using scana to check the signals coming from spi ports. My question here is that how can I send my data to scana rather than making a loopback. For instance first I have to ad a chip select for scana, adding ss=<13> to the overlay file can be the first step right? What should I change other than this?

     This driver doesn't have the concept of a chip select pin. A "ss-pin" component is typically setup by a driver, for instance at45, using a normal gpio as output.

    When using the driver directly, you should set/clear a dedicated GPIO for ss-pin usage. The blinky example in zephyr/samples/basic/blinky shows how to set/clear a gpio.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    verulia said:
    Thank you for the fast reply. I just ran the code however I am always receiving 0 in the RX_recv. Shouldn't the value in RX_recv be similar with TX_sent since this code is just tries to send a value and receive it back as far as I understood? I didn't make any change in the code yet.

    If you connect MISO and MOSI together, then you will receive what you send. 

     

    verulia said:
    I want to send data from nrf9160 to an external device, in order to just make a simple test before implementing a flash driver, I want to test the pins and spi, for that I am using scana to check the signals coming from spi ports. My question here is that how can I send my data to scana rather than making a loopback. For instance first I have to ad a chip select for scana, adding ss=<13> to the overlay file can be the first step right? What should I change other than this?

     This driver doesn't have the concept of a chip select pin. A "ss-pin" component is typically setup by a driver, for instance at45, using a normal gpio as output.

    When using the driver directly, you should set/clear a dedicated GPIO for ss-pin usage. The blinky example in zephyr/samples/basic/blinky shows how to set/clear a gpio.

     

    Kind regards,

    Håkon

Children
Related