Hardware Reference
In-Depth Information
In POSIX systems, such timing properties have been resolved by using a
struct
timespec
data structure, containing a 32 bit integer representing nanoseconds (thus
providing high resolution), and a 32 bit integer representing seconds (thus giving a
lifetime of around 136 years, more than enough for practical applications). Unfortu-
nately, this approach cannot be implemented on small microcontrollers, where han-
dling a 64 bit data structure imposes a significant overhead in the scheduler imple-
mentation. To overcome this problem, Erika adopts a circular timer [CB03], which
replaces the absolute timing reference with a timing reference relative to the current
time
t
, implemented by a free running timer.
In this way, it is possible to handle absolute deadlines that can range between
t
P/
2
and
t
+
P/
2, where
P
is the timer lifetime, defined as the minimum interval of time
between two non simultaneous events characterized by the same time representation.
For example, in a Microchip dsPIC microcontroller with a timer clock running at 2
MHz, the 32 bit hardware timer can achieve a lifetime of 1073 seconds (enough for
many practical applications).
−
If
t
(
e
i
) is the absolute time at which event
e
i
occurs, the circular time method can be
expressed follows.
If events are represented by
n
-bit unsigned integers, such that
P
2
∀
t
∀
e
i
,e
j
∈
E
(
t
)
|
t
(
e
i
)
−
t
(
e
j
)
|
<
(12.1)
∀
t
∀
e
i
,e
j
∈
E
(
t
) we have
then
P
2
1.
t
(
e
i
)
>t
(
e
j
)
⇐⇒
(
e
i
e
j
)
<
,
(
e
i
e
j
)
=0
P
2
2.
t
(
e
i
)
<t
(
e
j
)
⇐⇒
(
e
i
e
j
)
>
3.
t
(
e
i
)=
t
(
e
j
)
⇐⇒
(
e
i
e
j
)=0
where
denotes a subtraction between
n
-bit integers, evaluated as an unsigned
n
-bit
integer. It is worth observing that for 8/16/32-bit integers such a subtraction operation
does not require a special support since it is implemented in all CPUs.
Figure 12.1 shows a set of events that satisfies condition (12.1).
Search WWH ::
Custom Search