cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA TX RS485

SGian.1
Senior

Hi there!

I hope some one can help me. I use one STM32G031F4P6 for one my project, and i use the serial port with one RS485 ic, My problem is that i don't have any problem to receive the data from PC to micro controller the problem is the opposit receive data from micro controller. I use for receive and send data the DMA i try with the logic analizer and i saw the data. The problem look like him dosen't change the signal from low to hight on the DE port i think that's automatic o i'm wrong ?

Thanks a lot

Sergio

3 REPLIES 3
JPeac.1
Senior

Assuming you are using two-wire RS485 you must enable the transceiver for the transmit direction before sending data. You must also ensure the PC host switches from transmit to receive before you send, otherwise the two transmitters will collide when trying to send data.

In general, the data flow is to receive a message (which, as you say, works), then wait for the PC to disable the transmitter on its end (what's known as the turnaround time). After that you enable your transmitter on the STM32 side with the DE pin, send your message, wait for the USART to signal TC (transmission complete, last bit shifted out), and finally turn around the line again by disabling your transmitter.

It's very important that you do not turn around the line before the TC interrupt occurs on the USART. Do not assume the transmission is complete when DMA finishes. The USART buffers data, so if you reverse direction before the USART TC you will lose the final bits, causing framing or parity errors on the PC side.

There should be some mechanism on the PC side to control transmitter direction. Check your PC interface to see if it uses the RTS signal or something similar. Use a short delay during line turnaround to allow the RS485 bus to settle before turning on the transmitter.

@SGian.1​ " i use the serial port with one RS485 ic"

What IC do you use? How is it wired?

"The problem look like him dosen't change the signal from low to hight on the DE port"

You've got a logic analyser - so you should be able to see for certain if the DE is being correctly driven?

"i think that's automatic o i'm wrong ?"

What does the STM32 documentation (specifically, the Reference Manual) say?

SGian.1
Senior

Thanks for fast replace. I'm 99% sure JPeac.1  have a reason because i forced the pin DE Hight and i still dosen't see nothing on PC. Just for try i use docklight and a month's agoo i buy a rs485 to usb converter. But be onest i don't have any idea how configure docklight. Tomorror i connect anothe ic rs485 and with logic analizer i try to see if i receive a data

Tanks