SPI signal @16MHz looks terrible

Slinisa
Posts: 32
Joined: Sat Oct 07, 2023 8:21 am

SPI signal @16MHz looks terrible

Postby Slinisa » Mon Mar 25, 2024 7:54 am

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.
Attachments
4MHz.jpg
4MHz.jpg (145.61 KiB) Viewed 2047 times
16MHz.jpg
16MHz.jpg (140.64 KiB) Viewed 2047 times

Slinisa
Posts: 32
Joined: Sat Oct 07, 2023 8:21 am

Re: SPI signal @16MHz looks terrible

Postby Slinisa » Mon Mar 25, 2024 8:42 am

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.

MicroController
Posts: 1729
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: SPI signal @16MHz looks terrible

Postby MicroController » Mon Mar 25, 2024 10:18 am

Not a solution to your main problem, but to reduce the ringing you can try lowering the drive strength of the IO pins.

Slinisa
Posts: 32
Joined: Sat Oct 07, 2023 8:21 am

Re: SPI signal @16MHz looks terrible

Postby Slinisa » Mon Mar 25, 2024 12:21 pm

How can I do that?

Slinisa
Posts: 32
Joined: Sat Oct 07, 2023 8:21 am

Re: SPI signal @16MHz looks terrible

Postby Slinisa » Mon Mar 25, 2024 1:42 pm

It's ok, found it, gpio_set_drive_capability. It helped a bit.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: SPI signal @16MHz looks terrible

Postby mbratch » Mon Mar 25, 2024 4:20 pm

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?

Slinisa
Posts: 32
Joined: Sat Oct 07, 2023 8:21 am

Re: SPI signal @16MHz looks terrible

Postby Slinisa » Mon Mar 25, 2024 8:31 pm

I was hoping for 40Mhz, so yes, 16MHz is a bare minimum.

Who is online

Users browsing this forum: Google [Bot] and 115 guests