2017-09-27 10:51 AM
Hi,
I am trying to implement RS485 communication using STM32F030C8. I am using GPIO pin to control my external transreceiver(to change from transmission to reception) by controlling the driver pin of the transreceiver IC. I am able to transmit data(characters) to my PC serial terminal. But I am unable to receive any character from the serial terminal. I am able to do so using the RS232 protocol, but not in RS485. I checked with my debugger and it shows the program waiting for the RXNE flag to be set, that is, waiting for the data to be received in RDR register. What is it that my data is not being received in the RDR register while I implement for RS485?
Can anyone explain me the correct way to implement a RS485 communication using Standard Peripheral Library. (Any additional information if required can be provided.)
Thanks alot.
#stm32 #rs485 #receiver #usartSolved! Go to Solution.
2017-09-27 03:39 PM
>>What should be the ideal data form be like?
You'd think you'd already know this...
https://www.lookrs232.com/rs232/waveforms.htm
>>The data not being present in the form, is the data simply sent from a serial terminal.
You're asking why it isn't working, I'm suggesting to verify/validate the form of the data being presented at the USART_RX pin to understand why.
If there is no data, then no reception. If the data is not formed correctly, likely no data, or framing errors.
If the data is valid, then you need to review the configuration.
2017-09-27 11:21 AM
>>What is it that my data is not being received in the RDR register while I implement for RS485?
Data not presenting at the RX pin in a form/fashion suitable for reception? Get a scope or analyzer and review the performance of the circuit you have designed.
2017-09-27 01:44 PM
The circuit I have designed is simple transreceiver whose differential outputs are connected to a RS485 to USB CONVERTER. The data not being present in the form, is the data simply sent from a serial terminal. What should be the ideal data form be like?
Thanks.
2017-09-27 03:04 PM
I suppose, your USB-to-RS485 adapter at PC is a full duplex device: it must have two pairs of differential signals - one for RX and one for TX. Your transceiver, in opposite, is a half-duplex device, because you (have to) switch its direction by a GPIO. You seem to have connected the tranceiver with the receiver pair of the USB adapter and can send the data to the PC but cannot receive any from PC since the other, TX, pair of the USB adapter stays unused.
Solutions?
1. Use a full duplex tranceiver at the device side.
2. Tricky combine the pairs of the USB adapter to build a half-duplex connection to your device. For this purpose, connect at the USB adapter its TX+ to RX+ via, say, 1K resistor. TX- and RX- connect the same way. Your RS-485 half-duplex bus would be between RX of the USB adapter and your tranceiver. Note: first, you have to decide, what end has a priority: if your device is mostly expecting data from PC and replying to it, your device should be initially in the RX mode. Else, if the PC is a 'slave' end, expecting unsolicited data from the device, your tranceiver can initially stay TX active. Besides, your PC sould wait a bit after receiving data from your device before sending a reply because you have to switch your tranceiver from TX to RX.
If the PC sends data via TX, it would receive the echo at RX, so you have to take this behavour into consideration writing a communication program for the PC.
2017-09-27 03:39 PM
>>What should be the ideal data form be like?
You'd think you'd already know this...
https://www.lookrs232.com/rs232/waveforms.htm
>>The data not being present in the form, is the data simply sent from a serial terminal.
You're asking why it isn't working, I'm suggesting to verify/validate the form of the data being presented at the USART_RX pin to understand why.
If there is no data, then no reception. If the data is not formed correctly, likely no data, or framing errors.
If the data is valid, then you need to review the configuration.
2017-09-28 07:08 AM
Thanks Clive.The data not being received in the form was like a clue. I checked with an oscilloscope and found that the RS485 to USB converter was not able to produce output when data was sent from the terminal. Replaced the converter and it worked. Thanks.