Page 1 of 1

SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 7:54 am
by Slinisa
I've created dual SPI @16MHz, connected it's output to the controller itself, pins declared as inputs. I've connected SCK and MOSI to oscilloscope and the signal looks awful. I haven't tried to receive SPI message yet, but it's hardly going to work if it looks that bad.
The connection wires are within 20cm, I've also tried terminating it with a resistor and it sill looks awful. I've also tried to decrease the frequency to 4 MHz, and it sill doesn't look too good. Also tried with pull-ups and pull-downs, open drain ... to no avail.
Does anyone have any suggestion how to improve it?

Edit: also tried putting a capacitor in parallel (100 pF and 10 nF, I have nothing in between at home yet). 100pF doesn't do much, and 10nF almost kills the signal. Also tried leaving SPI pins floating and it looks just as bad.

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 8:42 am
by Slinisa
OK, I've shortened the length of wires by half and now it looks better. Still far from perfect, but I guess it will be fine when all components are on one PCB.
If anybody have any suggestions on still improving the signal, it would be much appreciated.

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 10:18 am
by MicroController
Not a solution to your main problem, but to reduce the ringing you can try lowering the drive strength of the IO pins.

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 12:21 pm
by Slinisa
How can I do that?

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 1:42 pm
by Slinisa
It's ok, found it, gpio_set_drive_capability. It helped a bit.

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 4:20 pm
by mbratch
OK, I've shortened the length of wires by half and now it looks better. Still far from perfect, but I guess it will be fine when all components are on one PCB.
For sure. Shortening distance, especially having the signals be on traces on a single PCB, and reducing frequency, if possible, will mitigate the issue. Does the application require that you run SPI at 16MHz?

Re: SPI signal @16MHz looks terrible

Posted: Mon Mar 25, 2024 8:31 pm
by Slinisa
I was hoping for 40Mhz, so yes, 16MHz is a bare minimum.