cancel
Showing results for 
Search instead for 
Did you mean: 

Communicate between STM32F7 and ESP-01 via UART

Paul_TESSON
Associate II

Hello,

I am reaching out to ask if it would be possible to get some help configuring my esp01.c library.

I am currently developing a library that utilizes DMA, interrupts, and a circular buffer to communicate with an ESP-01 module. The module is connected via PE7 and PE8 on an STM32F767ZI. However, I am encountering difficulties in properly configuring the DMA to handle two-step communication with the component.

Additionally, when I attempt to send the AT\r\n command, the DMA correctly processes the \r\n characters but does not seem to recognize the AT command.

You can find my code on GitHub. The relevant file is esp01.c, located in the SRC folder:
:link:GitHub - SMART_WAKE_UP_UV

Thank you in advance for your help.

Best regards,

5 REPLIES 5
Pavel A.
Evangelist III

So what you're really asking is how to do UART communication?

The STM32's UART neither knows nor cares what device is connected to its UART - all it does is send data out from its TX pin, and receive data coming in on its RX pin.

So the first step is to forget about the ESP-01, and just get your UART comms working with a PC terminal.

Start with plain, blocking reads & writes first before adding the complications of DMA.

https://wiki.st.com/stm32mcu/wiki/Getting_started_with_UART

https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Step3_Introduction_to_the_UART

https://community.st.com/t5/stm32-mcus/implementing-uart-receive-and-transmit-functions-on-an-stm32/ta-p/694926

See also the examples in CubeIDE.

Ok, I understand, but I code in bare metal with Kiel uVision5, because I would line to know how it works and I would like to reduce energy consumption.

The principle remains the same: start simple - just a terminal, no ESP, blocking.

Get the basics working first - before adding the complications of DMA, etc.

I would avoid DMA in this case.
Or can you guarantee transmission sizes of constant length ?
If not, you will probably get a DMA_TC interrupt only with the next transmission.

Use single-character reception in an interrupt, and check for '\r' or '\n' (or both).
When this termination character(s) are received, process the contents and trigger the response.

And as mentioned, UART is UART. The architecture of the CPU/MCU on the other side does not matter, as long as it sticks to the protocol conventions.