2014-09-16 02:54 AM
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-stm32f303vc2014-09-16 03:45 AM
In this mode, the end of one block is recognized by a “silence�? (idle line) for more than 2 character times.
This is not correct. The specification
http://www.modbus.org/specs.php
(Modbus Serial Line Protocol and Implementation Guide V1.02http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
) states 3.5 character times, which ought to be strictly observed for baudrates up to 19200. For higher baudrates, fixed times should be used (see page 13).2014-09-16 04:32 AM
Thanks for your quick answer fm, but i know this, thats why i set:
USART_SetReceiverTimeOut(USART3, 35); // Line idle for 35 bits
. (i assume that my packet has 10bits)I just copied what RM states, but that wasn't what i was asking. Im interested is if that function works as i think (described my understanding in first post).Thanks anyway,Cheers.2014-09-16 05:37 AM
I would understand the RM the same way.
While I never implemented the Modbus protocol on STM32, implementing and testing shouldn't be too difficult. I hope you are aware that not all USARTs support this receiver timeout feature (RM page 793).2016-09-30 03:28 AM
Hi Arth, I am new bee. & I want start task on Modbus RTU ,so I need help on STM32F303 DISCOVERY,can you please share a Modbus project file on stm32f303 for my reference.
2016-09-30 08:57 AM
You are unlikely to get a response on a 2-year old thread. Perhaps try Google, or reviewing chip documentation. Discuss with your project supervisor.
2016-10-01 03:11 AM