0

I am having troubles with my pi 4b, in which i could not push the spi beyond 5Mhz without the data being corrupted.

I have an spi slave that is capable of abaout 15MHz on the serial clock (32ns high + 32ns Low). I tested it to write to a register of my slave device and read it again to confirm if its actually written. Frequencies below 5Mhz it passes but anything above it just starts to fail badly.

My problem persist even if i use a different library, i tried it on SPIdev and pigpio. I even tried switching languages to python spidev and i still cant push it beyond 5MHZ

is my pi 4 busted?

7
  • Can you try 16MHz? – CoderMike Mar 22 at 20:11
  • @CoderMike i ran it at 16Mhz and sadly the behavior is the same – Jack Mar 22 at 20:20
  • Have you tried running it in C rather than Python? – Elliot Alderson Mar 22 at 20:41
  • @ElliotAlderson yes, pigpio is a c library, also i have done it with c spidev – Jack Mar 22 at 20:46
  • 1
    @joan its a HAT type pcb im pretty confident that the pins are not loose. Currently im asking a friend to let me borrow his card reader so i can try it on my second pi 4. i will update the post if the problem persist on the second pi. Im playing it safe not using the same sd just incase its an OS problem. – Jack Mar 22 at 21:18
1

A lot depends on your wiring. 15 MHz is a serous frequency which won't tolerate signal reflections in the wires or high capacitance. Try shorter wires, and exclude any unnecessary connectors, adapters, breadboards, etc. This includes wires you attach to the same pin which don't connect the Pi with the slave: if you attach a multimeter probe to a clock line, you will ruin the clock signal at 15 MHz, even if the line runs fine without the probe.

Also, the maximum frequency specified in the documentation often applies to very specific conditions. For example, Arduino can only work at 16 MHz with 5V supply, if you power it with 3.3V it is limited to 8 MHz. Another point is setup/hold time required for MISO/MOSI with respect to the clock. Read the docs carefully to make sure you can really achieve the maximum frequency.

Ultimately, you will need an oscilloscope if you want to diagnose problems related to signal integrity.

2
  • 1
    I actually went had a looked at it in the oscilloscope because i thought the same as you. But at 10Mhz the signal looks really good with no overshoots, its was a clean square wave. The problem i am seeing is the SCLK drops to <1Mhz when i set the spi speed to anything above 5Mhz. – Jack Mar 23 at 20:12
  • @Jack I don' t quite understand how (a) "at 10Mhz the signal looks really good" and (b) "he SCLK drops to <1Mhz when i set the spi speed to anything above 5Mhz". Did you manage to achieve 10MHz? – Dmitry Grigoryev Mar 24 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.