This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

SPI Master not working with Flash

I am working with the nrf51822 eval kit and custom boards based on the Laird BL600 module. I am using SDK v5.2.

I am trying to connect to external Flash (Microchip SST25VF016B) through SPI 1. No matter what I do, the Flash returns 0xFF.

I have tried the nrf51822 SPI loopback example, it works fine. Indeed, I can loop back MISO<->MOSI and read the correct data. So the nrf51822 chip seems to be working, at least with itself.

I also took the Flash chip and hooked it to an Arduino Pro Mini. With that setup, I can talk to the Flash just fine. So I am pretty confident that the Flash works and that I am hooking it up correctly as I have the two rigs next to eachother for reference.

I have made sure the mode settings and frequency are the same between the Arduino and the nrf51822. Also, just to try it, I used many different mode/frequency combinations. Nothing works. No matter what I do, I always get back 0xFF on the MISO line with the nrf51822.

I don't have a scope, unfortunately, so I can't debug at that level.

Anyone have any idea what could be causing this? Any idea at all? I am wide open as I am pretty much stuck and have been trying everything.

I posted the code I am using for reference. Here is the Arduino test (which works and properly prints the Flash ID): gist.github.com/.../6fd9709f76584b8af792

Here is the nrf51822 test (which doesn't work, and just returns 0xFF every time): gist.github.com/.../2bedc0ce3f7e2251174d

For the nrf51822, I am using the provided spi_master class. I have thoroughly gone through this and not changed anything in there except the frequency.

Parents
  • I analyzed both of the SPI transfers for the two codes on an Arduino and the nRF51822. The only difference between them is that on the nRF51822 the SS pin is set high and low again between every byte transfer.

    Try to add a bool stop_condition as an argument to the spi_master_tx_rx() and change the last line in the function to this

    if(stop_condition){
        nrf_gpio_pin_set(SEL_SS_PINOUT);
    }
    

    Now you can set the SS pin high after the last byte only.

Reply
  • I analyzed both of the SPI transfers for the two codes on an Arduino and the nRF51822. The only difference between them is that on the nRF51822 the SS pin is set high and low again between every byte transfer.

    Try to add a bool stop_condition as an argument to the spi_master_tx_rx() and change the last line in the function to this

    if(stop_condition){
        nrf_gpio_pin_set(SEL_SS_PINOUT);
    }
    

    Now you can set the SS pin high after the last byte only.

Children
No Data
Related