Showing results for 
Search instead for 
Did you mean: 

Hi I am using STM32L1 series microcontroller in meter when I connect my meter to MODBUS it become hang. I don't know what is the problem.

Associate II

Me neither.

Describe your problem in more detail. Firmware you are using (code snippets), type/parameters of connection, crash symptoms.

People here have no magic crystal balls.

What have you tried already ?

Sounds like you and your colleagues need to work on debugging and diagnosing the underlying issues. ​

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Jack Peacock_2
Senior III

Start with some basics:

1) is the serial protocol correct? Is it RS-485, half duplex? Are the + and - sides connected properly, with termination? Is your bus turn-around time correct?

2) can you see messages arrive from meter, or can you tell if meter receives messages?

3) For modbus, are both sides using same RTU or ASCII protocol?

4) are your inter-character and inter-frame gaps correct if RTU?

5) Did you verify baud rates on both sides are correct (i.e. use a scope, don't assume)? Your STM32 may not be using the PCLK source you think is correct for the baud rate (a common mistake).

6) Does your Modbus receive routine have a timeout? If not it will hang forever if anything is configured wrong.

7) Are you configured for 7-bit + parity if ASCII mode?

😎 Check your UART status for receive errors (framing, overrun, parity).

Jack Peacock

Associate II

I have written a book on Modbus slave design using C targeted to STM32: