cancel
Showing results for 
Search instead for 
Did you mean: 

About possibility of detection the Idle state in the UART

Vyacheslav Azarov
Associate III
Posted on November 09, 2016 at 04:51

I now develop Modbus transportation compatible with Modicon RTU and I was going to use the opportunity of detecting IDLE state by the UART. But the duration value of IDLE character is fixed and equal one frame. It is unfortunate that this parameter can not be programmed, such as guard time for the smart card mode. This makes it impossible to implement this popular protocol, without using an external timer. Maybe something I do not understand, and the ability to modify the duration of Idle symbol exist? Thanks in advance for the answer.

#idle-uart-modbus-rtu #idle-uart-modbus-rtu
2 REPLIES 2
jpeacock23
Associate III
Posted on November 09, 2016 at 10:08

Older parts (F1, L1) have this problem and require a timer to fix it.  Newer parts (L4, F4) have support for Modbus and use a programmable idle detect.

For the older parts you need to connect a timer input channel (I use TIM9) to the USART RxD pin and set it up to reset the timer on rising or falling edges (either or both).  Set the timer to the RTU inter-message gap period after receiving the first byte of the RTU message, and start it.  Incoming data pulses will reset the timer, indicating the line is busy.  When the timer times out the line is idle.  Not all timers reset on a channel pin so check the timer specs before using it.

  Jack Peacock
Vyacheslav Azarov
Associate III
Posted on November 09, 2016 at 15:35

Good, I know differences between L and F series also.

I also think what implement Modbus RTU compatibility  on the UARTS what not have adjustment of the IDLE duration very simply. For create delimiter of the frame need transmit 4 IDLE characters and for recognition delimiters of the frame need receive 2 IDLE characters continuously. This is somewhat different from the standard but will not affect to functionality.

...

But who can hint, how to send 4 IDLE characters? It is not very clear!

...

My tiny study of this problem leads to the conclusion. Send and receive a few characters IDLE seems impossible for ordinary UART such as contained STM32F103.

...

The best way is to apply the appropriate controller.