Raspberry Pi SPI fault – returning incorrect bits
Ask QuestionAsked todayActive todayViewed 25 times0
I’m currently trying to interface a CS5530 ADC to a raspberry pi 4b 8g using SPI. When I attempt to communicate with the ADC I repeatly get return bits that make no sense and am running out of ideas to trouble shoot. When using the Spidev-test script I’m recieving the following response:
spi mode: 0x4 bits per word: 8 max speed: 2000000 Hz (2000 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D
RX | FF FF FF FF FF FF FF F8 00 00 00 27 F8 00 00 00 27 F8 00 00 00 27 FF FF FF FF FF FF FF FF FF FF
As you can see there’s something causing the MISO line to be recieving incorrect bits. If I use a jumper from MOSI to MISO to the bits return as should be expected. I’ve tried different clk speeds while staying under 2MHz as that is specified as the make clk speed in the cs5530 data sheet. I’m also recieving similar junk back using the spidev libary in python.
I’m thinking the most likely problem I have is for some reason the clk on the rpi isn’t producing a proper signal. I don’t own logic analyser (thinking I’ll properlly have to order one) so I’ve mapped the signal the best I can using piscope.
this image shows what looks like to me the clk line not functioning as you should expect.
I’m a novice at this sort of thing but it looks to me that the clk line is all over the show instead of regular sine wave you’d expect to see there. I’m not sure if this is what’s casuing me issues or if it’s due to the limitations of piscope.
this imagine also shows similar behaviour happening when I’m shorting MOSI and MISO to test the lines.
So while I think I’ve found the cause of my issues I’m about out of ideas of what could be causing this issue and how to fix it. So far all the things I’ve tried when trying to troubleshoot this is:
- Swapping out Raspberry Pi’s – Problem presists exactly the same.
- Swapping out cs5530
- checked all my solders on the prototyping board and continuity between all points, test resistor values and cap’s are all at correct values. Swapped crystals due to not having a scope to test it.
- Tested the cs5530 at both 3v and 5v modes (using an external power supply)
- Grounded rpi to external power supply
- Tried running a cs5530 off rpi 3.3v supply
- set core_freq=250 on rpi
- set dvfs=2 to rpi to prevent any issues caused by core being under voltaged
- tested on spi0 (CE 0 and 1) and spi1
temp was 53 degrees when the tests in the pictures where done so I think I can rule out thermal throttling as well. At this point I’m completely out of ideas what else to try. Might be worth noting that I am booting off a high quality 16gb USB flash drive, I haven’t bothered coping the img to a sd card just yet as I wouldn’t have thought that this would be causing any problems but I might try it just to fully rule that possiblity out.
Thanks in advance for any help, hoping that there’s someone much smarter than me out there that can shine some light on this for me.
Cheersadcraspberry-pispiShareCiteEditFollowFlagedited 1 hour agoasked 3 hours agoJake Wansink111 bronze badge New contributor
- 1I think your scope is lying to you – it looks like the sample rate is too slow. A sine wave is not what is expected! At a quick guess, I’d suggest you try changing the CPHA option. Along with CPHA you have 4 combinations. Only 1 will work. – Kartman 1 hour ago
- Ah, let me see. (1) You said the following: “If I use a jumper from MOSI to MISO to the bits return as should be expected, …” Your SPI loop back test shows that Rpi4B SPI software and hardware are “more or less” working OK. – tlfong01 41 mins ago
- (2) I skimmed the datasheet :Low-Cost, Low-Noise 24-bit ADC – Cirrus Logic cirrus.com/products/cs5530, and found the following features need to be looked at very closely: (a) Simple three-wire serial interface, SPI and Microwire compatible, (b) Schmitt-trigger on serial clock (SCLK), … (d) Selectable word rates: 6.25 to 3,840 sps. Both comments “Schmitt triggered SCLK” and “Word rates 6.25 to 3,840 sps” are spec comments not usually found in ADC data sheets. – tlfong01 27 mins ago
- (3) Anyway, I skimmed the datasheet: CS5530 24-bit ADC with Ultra-low noise Amplifier Datasheet – Cirrus Logic, statics.cirrus.com/pubs/proDatasheet/CS5530_F3.pdf. I read the following sections more carefully: 2.2.4 Reading and writing On-chip Registers, 2.3.2 System Reset Sequence, 2.3.3 Input Short, 2.3.7 Word Rate Select, 2.5.1 Single Conversion Mode. I will later suggest how to troubleshoot this Cirrus Logic 24-bit ΔΣ ADC with reference to the above sections. – tlfong01 5 mins ago Edit Delete
Leave a Reply