Author Topic: What are the Hardware Timer Requirements for the Modbus Module  (Read 12754 times)

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Hi Mark,

What are the Hardware timer requirements for the Modbus module? I'm using Luminary Micro LM3S1968 chips with Modus RTU half duplex RS485 running at 115200 baud.

I think I've pretty much answered my own question, I've just found the section on Hardware timers in the modbus manual

I need to support 4 x Modbus serial channels, 3 using the the LM3S1968 built-in UARTS and one using an external SPI uart, probably the SC16IS7xx mentioned here http://www.utasker.com/forum/index.php?topic=998.0

From my reading of the Modbus source code each Modbus serial channel requires a hardware timer, for RTS timing? The chip contains 4 x Timers with one I presume being used for the timer tick, so theoretically I have 3 timers left which should be enough. Is my understanding correct. The SC16IS7xx as you know handles RTS control automatically. It maybe that I still need timers 4 timers as I need 1.5 and 3.5 character timers for all 4 channels.

I was also wondering if it was possible to do everything with just one hardware timer, that could be set to just interrupt for the shortest period required? It would make the timer interupt handler more complex but more flexible

Cheers

Martin
« Last Edit: August 18, 2010, 05:54:11 PM by mhoneywill »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: What are the Hardware Timer Requirements for the Modbus Module
« Reply #1 on: August 18, 2010, 05:57:09 PM »
Hi Martin

The HW timer use is specified in appendix B of the MODBUS User's guide. Here is the excerpt:

Quote
Depending on the target processor and the operating modes supported by the MODBUS module some hardware timers may be required. The timers are used to perform the following functions on serial MODBUS ports:
•   RTU inter-character space timing. One timer per UART receiver, unless the UART contains an idle line timer built in to its hardware.
•   RTS line control in RS485 mode. One timer per UART transmitter when this mode is used, unless the UART supports RS485 operation in HW or has other timing suitable for control without extra delays.
Note that these two functions can be performed by a single hardware timer since their activities never overlap during MODBUS operation. This is true due to the fact that the MODBUS protocol is not full-duplex in nature and so only either the receiver or the transmitter is ever active at any specific point in time.
Furthermore it is possible to allocate the same hardware timer to control the operation of multiple UARTs as long as the UARTs are not used at the same time. This restriction is however not practical in the majority of MODBUS systems.
The following section details the timers used and the method of configuring the specific hardware.

If you don't need either RTS or RTU timing on a particular channel then no HW timer is required for it.

Since you are using A Cortex M3 device the system TICK is taken from the SYSTICK in the Cortex core and not from a general purpose timer. This means that, assuming the application is not using further HW times, you have 4 available in the LM3S1968. Maybe you are lucky...;-).

Regards

Mark

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: What are the Hardware Timer Requirements for the Modbus Module
« Reply #2 on: August 18, 2010, 06:17:32 PM »
Yes, I've just found that section about the SYSTICK so I think I'm Lucky :), Just have to make sure I don't need any more timers.

I will give the idea of using one timer for all modbus timing some thought as it might provide a more scalable solution.

Cheers

Martin