This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to detect a silent interval?

Hi,
In Modbus protocol, RTU mode, use 3.5 charater silent time as a message start or end in current BPS, how can i detect this interval, use a timer or ...? (the mcu i use is at89c52, timer0 is used as a 1ms timer interrupt, timer1 use for baud rate generator)

  • Hi, Liu.

    I'm looking for the same information.
    Did you find it?
    If you did, could you please send to me, 'cause I do'nt know how to do this on 89C52.

    Thanks,

    Giovani Guidolin

  • Don't most '52 derivatives have a Timer2?

  • There's the suggestion in

    http://www.keil.com/forum/docs/thread3738.asp

    about timestamping the last event. For fairly low serial rates, the 1ms timer tick would do. (That's about 1 character time for a 9600 bps UART.)

    The Modbus specs are "at least" 3.5 character times, I think, so being too slow only hurts throughput rather than correctness. Once the data rate hits about 40 kbps, this will start to be a factor.

    Perhaps you could use the BRG timer to measure 4 character silent intervals (when it's not in use as a BRG)? You'll have to be able to switch the timer mode in half a character time, which again shouldn't be too bad at low data rates. It should be only a dozen or so instructions.

    Depending on what else your application has to do, a delay loop might suffice. You could code one that watches the timer value for that 1ms timer tick. Search the forum for a number of good threads on ways to code delay loops.