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

SPI slave data offset

I'm using the 0.9.2 SDK SPI slave example to connect to a SPI master (Atmel SAM4S). When I initiate a SPI transfer from the master side I can see that all the data arrives correctly on the nrf52 side (ABCDEFGHIJKLMNOP) every time. However, on the master side I get only ORC (0x55) characters. Now I did some experimenting and if I request less data than the buffer I do get some of the data on the master side but it looks to be offset by the amount minus one. Eg.

Sending(amount) - Received data(on master):

1 Byte - a

2 Bytes - bc

5 Bytes - efghi

Due to the fact that I see data on both sides I do not assume the SPI connection is faulty. Otherwise I would just see garbage. This is way to systematic of an issue. Anybody have an idea what could go wrong here?

  • I solved the issue by looking at it on the logic analyzer. Apparently there were two issues:

    • On the master side I didn't deselect the chip select before reading the SPI RX data which apparently resulted in extra frames sent on the SPI bus. Therefore the shift.
    • I still saw 0xAA's for the first Byte in every transaction. Turns out that the timing was off froCS going low to the first clock toggle. Once the delay was large enough all the data is correctly transmitted to both sides. Closing.
Related