最近在参考freemodbus源码做tivaC系列tm4c123gh6pm芯片的modbus通信协议移植,因为需要计算通信的超时时间,所以产生标题中提到的两个问题:
1:tivaC系列芯片的timer是按照振荡周期计数还是按照机器周期计数?(查阅网上部分51单片机资料提到51系列好像是按照机器周期计数,与振荡周期的比值为1/12,不知道tiva系列定时器的周期如何计算?)
2:按照freemodbus源码中给出的计算公式,超时判断的时间值为传输3.5个bit所需要的时间,因此想知道UART在连续发送数据时,各帧(字节)之间时间间隔大致为多少,如此设置是否合理?
还请不吝赐教,谢谢。
freemodbus源代码如下:
/* If baudrate > 19200 then we should use the fixed timer values * t35 = 1750us. Otherwise t35 must be 3.5 times the character time. */ if( ulBaudRate > 19200 ) { usTimerT35_50us = 35; /* 1800us. */ } else { /* The timer reload value for a character is given by: * * ChTimeValue = Ticks_per_1s / ( Baudrate / 11 ) * = 11 * Ticks_per_1s / Baudrate * = 220000 / Baudrate * The reload for t3.5 is 1.5 times this value and similary * for t3.5. */ usTimerT35_50us = ( 7UL * 220000UL ) / ( 2UL * ulBaudRate );