Slave SPI is not collecting data

HEckardt
Posts: 31
Joined: Wed Aug 16, 2023 3:13 pm

Slave SPI is not collecting data

Postby HEckardt » Fri Jul 18, 2025 3:23 pm

Dear Community,

I'm using a ESP32 WROOM-32D. It should work as a SPI slave connected to a PIC32. This SPI is working very well, cecause there are some other devices connected.

I adapted the SPI excample from the Espressif to my setup (see att. main.c, he_spi.h). In the main loop I inserted a timer with a counter, just to see the progran is alive. To have a visible pattern, I preload the first Byte of the SPI-receive-buf with 20 and print this Byte out, bevore and after the SPI is receiving a Byte. The PIC-MCU ist sending a 0xA5 (see OsziPIC MOSI signal).
c_files.zip
(2.13 KiB) Downloaded 16 times
The problem is, the Byte after receive is not changed in the receive buf. I expect the 0xA5 (165 dec) but it is still the 20 (dec). The Oszi-PIC is showing, that the ESP SPI is sensing the transfer, because the MISO line is clocking the 1, whitch is preset in the ESP SPI send-buf. As you can see in the TerminalOut, I tryed it several times (after Main Loop 11, 19, 25).

[*]
SPI ready

wait for PIC

start wait for PIC 20

Main Loop 0


Main Loop 1
.
.
.
.
.

Main Loop 11


post wait for PIC 20

start wait for PIC 20

Main Loop 12
.
.
.
.

[*]

Each time with the same result. I checked the ESP MOSI pin. I configured it as a ordinary GPIO input and verified the correct high/low lewel. For my verivication, I puted the relevant code into the main.c, but with the same failure.

I attached my .c files for your information.

For my opinion, there should be somthing wrong with the memory setup. But up to now no idea about a solution.

What could be wrong?

Greetings
Henry
Attachments
TerminalOutput.txt
(4.95 KiB) Downloaded 7 times
OsziPic.jpg
OsziPic.jpg (57.22 KiB) Viewed 229 times

HEckardt
Posts: 31
Joined: Wed Aug 16, 2023 3:13 pm

Re: Slave SPI is not collecting data

Postby HEckardt » Fri Jul 18, 2025 3:28 pm

Sorry,

the mistake by insertion of the att. files. But the problem is visible.

Henry

wanckl
Espressif staff
Espressif staff
Posts: 6
Joined: Mon Sep 11, 2023 8:24 am

Re: Slave SPI is not collecting data

Postby wanckl » Tue Aug 05, 2025 8:39 am

Hi, for esp32 it use an old design, If you using DMA and actual transaction length (master side) not align to 4 byte, slave can't receive those not aligned bytes.

So for your solution: change PIC master side that transaction length align to 4 bytes, Or not use DMA on esp32 spi slave.

Thanks for your report!

HEckardt
Posts: 31
Joined: Wed Aug 16, 2023 3:13 pm

Re: Slave SPI is not collecting data

Postby HEckardt » Wed Aug 06, 2025 7:28 am

Hi wanckl,

thank you for your replay.
right now, I'm not on my desk, so I cannot verify your solution. But I will check it out when I`m back. I give a feedback to you, if I did it.

One more question:
is the number of bytes exact four? Or is this the minimum for a transaction together with the DMA and it could be more?

Greetings
Henry

Sprite
Espressif staff
Espressif staff
Posts: 10617
Joined: Thu Nov 26, 2015 4:08 am

Re: Slave SPI is not collecting data

Postby Sprite » Thu Aug 07, 2025 12:01 am

It needs to align to four, in other words, be an integer multiple of four. So 0 bytes, 4 bytes, 8 bytes, 12 bytes, 16 bytes, 20 bytes etc all should work.

HEckardt
Posts: 31
Joined: Wed Aug 16, 2023 3:13 pm

Re: Slave SPI is not collecting data

Postby HEckardt » Thu Aug 07, 2025 10:16 am

Hi Sprite,

thank you for clarifikation. It's moving me ahead.

Great.
Henry

HEckardt
Posts: 31
Joined: Wed Aug 16, 2023 3:13 pm

Re: Slave SPI is not collecting data

Postby HEckardt » Fri Aug 08, 2025 10:14 am

Hi Sprite and wanckl,

thank you for your great support. I checked out your advices (with/without DMA) and could verify the solution.


Greetings
Henry

Who is online

Users browsing this forum: PetalBot, Qwantbot and 4 guests