Specifications

7.4. SOFTWARE DESIGN
the RTC’s interrupts (“timer s”). It uses an eight bit counter and thus
has a maximum period of 256 seconds. Also provided is the ability to
create blocking delays in the order of milliseconds, in the range of 0 - 65.5
seconds (“delay ms”). This uses hardware Timer0. All three timers operate
independently and can be used in conjunction with one another.
Timer ms is purely hardware based. A function was developed which
calculates the required modulus value to provide the required period. An
inline definitiion allows the programmer to call “timer ms expired()” which
checks the interrupt flag and returns true when the requested time has
expired. This is built on top of the timer functions provided by Microchip’s
C18 libraries.
To start timer
s, a function is called w ith the required time period in
the argument. This changes the timer s state to “running” and preloads
the given argument into a timer variable. An FSM in the RTC ISR. Every
second, the timer variable is decremented until it reaches zero. At this point,
the FSM changes state to “timed out”. The application which initiated the
timer polls this state variable for the timed-out condition.
Delay ms is a blocking function taking an unsigned 16 bit integer argument
of the required delay in milliseconds. The delay loops hardware Timer0 as
many times as necessary to create the required delay.
These functions are used by various FSMs to implement time-out functions.
For example, “timer ms” is used by the I
2
C FSM to create a 250ms time-
out and “timer s” is used by the GSM FSM for startup and email sending
timeouts.
7.4.7 GSM FSM
The Telit GM862QUAD employs standard GSM AT commands. Communication
takes place via standard RS232 serial lines. The module has an on-board
TCP/IP stack, FTP client and Email client and support for python scripting.
As mentioned in Section 7.2.1, we have decided to use email as the primary
data delivery method. It was initially assumed that the GM862 ’s on-board
email client would be used, however, this was later changed to use a custom
SMTP client due to limitations of the Telit module. The GSM FSM consists
81