Question
Modbus/RTU on STM32F303
Posted on September 16, 2014 at 11:54
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.so:1) I configure my timeout function: USART_SetReceiverTimeOut(USART3, 35); // Line idle for 35 bits USART_ReceiverTimeOutCmd(USART3, ENABLE); // Enable receiver timeout function2) Enable receiver timeout interruptUSART_ITConfig(USART3, USART_IT_RTO, ENABLE); 3) In USART IRQ Handler:void USART3_IRQHandler(void){ if(USART_GetITStatus(USART3, USART_IT_RTO) != RESET) { 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 ? #need-help:modbus-rtu-stm32f303vc