Hi,
I'm working on a MODBUS RTU slave "driver" for PBP. MODBUS messages are sent in frames and the slave is detecting the end of frame by using TMR0 as a timeout timer, generating an interrupt when it overflows.
The MODBUS specification says that for baudrates over 19200 baud the interframe delay can be fixed to 1750us but at 19200 baud and below it should be 3.5 "character times", example: 2400baud, 8 databits, 1 start, 1stop, 1 parity = 3.5*11bits/2400bits per second=16ms.
I'll divide the actual question in two:
1) Let's say I fix the baudrate at 38400 baud. Can I, and if so how, make the compiler/assembler calculate the correct TMR0 reload value (for 1750us in this case) for me based on the DEFINE'd oscillator speed?
2) If the above is possible can I extend on that and have it calculate the correct reload value for different baudrates as well? Fixed at 1750us for baudrated over 19200 and 3.5 characters "long" for 19200 baud and below.
Thanks!
/Henrik.
Bookmarks