cancel
Showing results for 
Search instead for 
Did you mean: 

SPI DMA - Communication between STM32H753ZI and ESP32S

Yusei
Associate

Hi,

I'm trying to set up SPI communication between a STM32H753ZI (Master, using SPI2) and an ESP32-S (Slave), using the ESP32SPISlave library.

Setup:

  • STM32 SPI2 pins:

    • PB10 (SCK) → ESP32 GPIO18

    • PC2 (MISO) ← ESP32 GPIO19

    • PC3 (MOSI) → ESP32 GPIO23

    • PE11 (CS) → ESP32 GPIO5

  • SPI Mode 0, 8-bit, NSS controlled manually (software)

  • GND is shared, 3.3V logic

  • Prescaler (for Baud Rate) 256
  • SYSCLK 400MHz

The STM32 sends 0x55 and expects a reply (ESP32 sends 0xAB via transfer()), but I always receive 0x00.

CS is pulled LOW just before HAL_SPI_TransmitReceive() and HIGH after. The transfer function does not block.

Question:

Why is STM32 always reading 0x00 on MISO, even though the ESP32 slave is responding with data? Any ideas or STM32-specific SPI2 issues I should check?

I don't know how I have to configure the ESP's clock, same with the STM32..

Thanks in advance!

3 REPLIES 3
TDK
Super User

Remove the ESP32 and connect MOSI to MISO on the STM32 to see if it receives what it sends. If it does, STM32 is doing its job.

Use a logic analyzer to figure out what is being sent on the line.

If you feel a post has answered your question, please click "Accept as Solution".
Yusei
Associate

If I connect the MOSI to MISO of the stm, I get the correct value.

I will think about buying a logic analyzer, thank you for the advice, I didn't know this device!

> If I connect the MOSI to MISO of the stm, I get the correct value.

Good, shows STM32 working/receiving as expected.

Since you're controlling CS manually, not much else could be to blame other than the ESP32 behavior.

If you feel a post has answered your question, please click "Accept as Solution".