SPI Problem

DrMickeyLauer
Posts: 180
Joined: Sun May 22, 2022 2:42 pm

SPI Problem

Postby DrMickeyLauer » Thu Jan 30, 2025 2:33 pm

My ESP32S3 is communicating with a TI DAC 81401 via SPI. As per the datasheet, the 81401 uses CPOL=0, CPHA=1, ergo MODE_1.
For some reason though, the ESP32 does not properly detect the answers. It comes out as 1 bit shifted to the right, i.e. where I should be getting 810A70, I'm getting 0214E0.

The scope's SPI decoder is in line with what TI says. MOSI seems to be okay, since the TI DAC does what it's supposed to be. Here's a screenshot:
ScreenImg.png
ScreenImg.png (79.19 KiB) Viewed 3689 times
C1=CS, C2=SLCK, C3=MOSI, C4=MISO (mixed MISO and MOSI up @ the scope)

This is even with very low bitrates (1MHz) -- do you have any idea what could be wrong?

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

Re: SPI Problem

Postby MicroController » Thu Jan 30, 2025 10:25 pm

DrMickeyLauer wrote:
Thu Jan 30, 2025 2:33 pm
C1=CS, C2=SLCK, C3=MOSI, C4=MISO (mixed MISO and MOSI up @ the scope)
Huh??? The scope traces are supposed to be digital signals?!
How can they degenerate so much? It looks like you have huge capacitances on&between the lines.
Master+slave are connected to a common GND?

DrMickeyLauer
Posts: 180
Joined: Sun May 22, 2022 2:42 pm

Re: SPI Problem

Postby DrMickeyLauer » Fri Jan 31, 2025 10:37 am

Yes, they share a common ground. This is a Texas Instruments DAC81408EVM connected via jumper wires to an ESP32S3. It's quite a complex board with lots of jumpers for different operational behaviors, but I think I got it setup correctly. So in your opinion it's the signal quality and not anything with bit timing?

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

Re: SPI Problem

Postby MicroController » Fri Jan 31, 2025 11:33 am

DrMickeyLauer wrote:
Fri Jan 31, 2025 10:37 am
So in your opinion it's the signal quality and not anything with bit timing?
Definitely. I didn't realize the scope was showing the SPI signals until I read the line below the image :)
I'd expect it to look something like this for example:
Image

DrMickeyLauer
Posts: 180
Joined: Sun May 22, 2022 2:42 pm

Re: SPI Problem

Postby DrMickeyLauer » Mon Feb 03, 2025 2:38 pm

I rewired and used scope probes w/ 10x. Does that look better now?
ScreenImg-11.png
ScreenImg-11.png (65.23 KiB) Viewed 2545 times
Here with a slower bitrate:
ScreenImg-12.png
ScreenImg-12.png (74.89 KiB) Viewed 2541 times
Still the same outcome though. The scope correctly detects 810A70, the ESP32 detects 0214E0.

DrMickeyLauer
Posts: 180
Joined: Sun May 22, 2022 2:42 pm

Re: SPI Problem

Postby DrMickeyLauer » Mon Feb 03, 2025 2:59 pm

I take that back. It might have been a combination of bad wiring and bad configuration. The TI DAC's SDO pin can be configured whether it latches @ rising or falling edge ­– irrespective of being a CPHA=1 device. In some of my tests I had that configuration backwards and with different settings it now seems to work:
ScreenImg-13.png
ScreenImg-13.png (74.9 KiB) Viewed 2532 times
Here we see that the bit is valid @ the falling edge and this seems to be what the ESP32 expects when using CPHA=1. Phew.

Who is online

Users browsing this forum: No registered users and 78 guests