2021-03-26 02:06 PM
When you configure a USART for the STM32G484 in CubeMX, it gives you a choice of RS485 or Modbus (but not both!). Yet, Modbus RTU runs *on top of* RS485, so this makes no sense. The Modbus configuration appears to put the MCU USART into half-duplex mode. I have seen RS485 implementations that use RTS with an external driver to switch from send to receive, so perhaps the setting in CubeMX is made in consideration of how the provided and instantiated drivers work?
Is there any modbus application example (with circuitry?) for CubeMX's "Modbus" configuration or even an external driver configuration?
Any thoughts are much appreciated.
2021-03-26 02:43 PM
Hi,
STM32G4 series does not support hardware protocol Modbus RTU.
From the RM0440 for STM32G4 page 1620: The USART offers basic support for the implementation of Modbus/RTU and Modbus/ASCII
protocols. Modbus/RTU is a Half-duplex, block-transfer protocol. The control part of the
protocol (address recognition, block integrity control and command interpretation) must be
implemented in software.
The USART offers basic support for the end of the block detection, without software
overhead or other resources.
If You want use Modbus RTU please look on free solution on the site: https://www.embedded-experts.at/en/freemodbus-downloads/
Best Regards,
Slawek
2021-03-26 03:32 PM
Hi Slawek, will the freemodbus work with the USART in "Modbus" mode (single bidirectional IO) or the "RS-485" mode (RX, TX, DE pins allocated)? Do you know if there is a reference hardware design for use with the "Modbus" mode? The "RS-485" mode uses very standard driver chips so I can design that myself.
Thanks!
Eric
2021-03-26 10:49 PM
Hi Eric,
If You use freemodbus the USART should be work normally in asynchronous mode. For the RS485 You should define DE Pin which will changed by library freemodbus.
Best Regards,
Slawek