Skip to main content
ENovk.1
Associate II
March 26, 2021
Question

STM32G484, RS-485 and Modbus - how to configure in CubeMX???

  • March 26, 2021
  • 1 reply
  • 5698 views

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.

This topic has been closed for replies.

1 reply

SKacp.1
Associate
March 26, 2021

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

ENovk.1
ENovk.1Author
Associate II
March 26, 2021

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

SKacp.1
Associate
March 27, 2021

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