AnsweredAssumed Answered

Modbus/RTU on STM32F303

Question asked by Vycas.Arturas.001 on Sep 16, 2014
Latest reply on Oct 1, 2016 by rao.manjunath
Hello everyone, i am implementing Modbus/RTU protocol on STM32F303 and i want to check something, because i don't know if i understand this correct. According to RM ModBus/RTU: 
In this mode, the end of one block is recognized by a “silence” (idle line) for more than 2 
character times. This function is implemented through the programmable timeout function. 
The timeout function and interrupt must be activated, through the RTOEN bit in the 
USART_CR2 register and the RTOIE in the USART_CR1 register. The value corresponding 
to a timeout of 2 character times (for example 22 x bit time) must be programmed in the RTO 
register. When the receive line is idle for this duration, after the last stop bit is received, an 
interrupt is generated, informing the software that the current block reception is completed.

1) I configure my timeout function:
 USART_SetReceiverTimeOut(USART3, 35); // Line idle for 35 bits
 USART_ReceiverTimeOutCmd(USART3, ENABLE); // Enable receiver timeout function
2) Enable receiver timeout interrupt
3) In USART IRQ Handler:
void USART3_IRQHandler(void)
    USART_ClearITPendingBit(USART3, USART_IT_RTO); // Clear RTO bit

Communication flows, i tested it and it works, so if you don't have any observations that i did something wrong, my question is as follows:
How this function actually works: USART_SetReceiverTimeOut(USART3, 35);
Does this mean that after last stop bit is received, interrupt will be generated after 35 baud clocks? I mean if my USART baud rate is 9600, so this interrupt will be generated after (1000ms/9600)*35 = 3,65ms , after last stop bit is detected ?