Skip to main content
Explorer
July 10, 2025
Solved

Request for Modbus RTU Example Code for STM32H747I-DISCO

  • July 10, 2025
  • 3 replies
  • 634 views

Hi,

I am currently working on integrating Modbus RTU communication using the STM32H747I-DISCO board. Unfortunately, I have not been able to find any official example code or reference implementation specific to this board.

I have already attempted to integrate the protocol using a sample code I put together, but it is currently not working as expected. I would greatly appreciate it if you could review the attached code and let me know if there are any issues or missing components.

If you also have a working example or any official reference for implementing Modbus RTU (ideally using UART, FreeRTOS, and the CM4 core), it would be extremely helpful.

Thank you in advance for your support.

    This topic has been closed for replies.
    Best answer by Ozone

    Download seems not to work, probably an issue of ST's side.

    Anyway, the Modbus protocol is not very widespread, except in the PLC niche.
    Therefore, and because of limited bandwidth, there are not many implementations and examples.

    However, there are quite a few open source implementation you can check out, many of them supporting Cortex M or similiar architectures.
    You would only need to implement the HAL layer (UART transmission), the more abstract frame processing should require very little modification, if at all.
    In other words, I would recommend to check out implementations not specifically for the STM32.

    Somewhat critical is the 3.5 character inter-message break.
    The implementation depends on the available features of the UART peripheral.
    And, having dealt with Modbus some years ago, I witnessed that several commercial products did not stick to the specs very well. In short, I would tolerate inter-message breaks down to 2.5 characters long.

    And second, many devices support baudrates beyond the upper limit of the specification, which is 38400bps.

    3 replies

    OzoneAnswer
    Explorer
    July 10, 2025

    Download seems not to work, probably an issue of ST's side.

    Anyway, the Modbus protocol is not very widespread, except in the PLC niche.
    Therefore, and because of limited bandwidth, there are not many implementations and examples.

    However, there are quite a few open source implementation you can check out, many of them supporting Cortex M or similiar architectures.
    You would only need to implement the HAL layer (UART transmission), the more abstract frame processing should require very little modification, if at all.
    In other words, I would recommend to check out implementations not specifically for the STM32.

    Somewhat critical is the 3.5 character inter-message break.
    The implementation depends on the available features of the UART peripheral.
    And, having dealt with Modbus some years ago, I witnessed that several commercial products did not stick to the specs very well. In short, I would tolerate inter-message breaks down to 2.5 characters long.

    And second, many devices support baudrates beyond the upper limit of the specification, which is 38400bps.

    Graduate
    August 6, 2025

    @Shealtiel : Are you still looking at Modbus RTU for H7 ?

    mike

    Visitor II
    September 28, 2025

    In case you are still looking.

    We made this library originally for a very similar MCU (STM32L4 and STM32H5), I could provide some specific examples for how to implement it with CMSIS if you are interested.
    https://github.com/SiemensEnergy/c-modbus-slave