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

SPI example code for nRF51822 Eval Kit

Hi, I tried uploading the example code from \nrf6310\spi_master_example to nRF51822 evaluation kit board, but no matter what I do, I always get SPI error. Not compile or upload code error, but the actual SPI error.

I've set the ERROR_PIN_SPI0 to LED0 and ERROR_PIN_SPI0 to LED1, and both LED turns on when I run the code, which leads me to believe that the code is successfully compiled and uploaded, but the SPI is not working.

I've already changed the pin numbers on the spi_master_config.h for SS, MISO, MOSI and CLK to match the pins that connect to my SPI device (in my case, it's ADXL362 accelerometer, made by Analog Devices)

Also, I find it strange that there isn't any code for PCA10001 board regarding SPI. This makes me wonder if the code in \nrf6310\spi_master_example is actually usable or not for eval kit.

Parents
  • I see, I'm currently using that example code (spi_master_example_with_spi_slave). However, my RXD always returns zero even though it was supposed to read a register with value of non-zero.

    I've made sure to read the accelerometer datasheet (if you are interested here's the link: www.analog.com/.../ADXL362.pdf, page 19 onwards)

    I've also made sure that I'm using the correct SPI Mode, correct clock, correct pin numbers and tried reversing the bits, but to no avail. I'm truly confused now, because I strongly believe this code should work, unless there is something else I need to do in that example code that I need to change to enable RXD to receive data? I don't think the component is broken either, although there is no indicator or such, so it is a hard to say in that regard.

    Here is my code, if you don't mind checking: SPI Accel.zip

  • Hi David,

    1. If you're using the eval-kit, the pins 8/9/10/11 are connected directly to the SEGGER chip, and it will drive some those lines high. Try changing them to other GPIOs.

    2. You're using printf. Have you mapped printf to something? If not, it will crash the program.

    3. Have you tried scoping the SPI lines to see if the data going over the bus is sensible?

    4. It is good practice to never let a embedded program return from main. add a while(1) in main.

Reply
  • Hi David,

    1. If you're using the eval-kit, the pins 8/9/10/11 are connected directly to the SEGGER chip, and it will drive some those lines high. Try changing them to other GPIOs.

    2. You're using printf. Have you mapped printf to something? If not, it will crash the program.

    3. Have you tried scoping the SPI lines to see if the data going over the bus is sensible?

    4. It is good practice to never let a embedded program return from main. add a while(1) in main.

Children
No Data
Related