Deterministic
Realtime Reaction
The OO RTX needs a regular heartbeat. If your product
does not come with an RTOS extention, you must provide a heartbeat
yourselves, and a common way to do that is to use a timer interrupt.
The Interrupt Service Routine must call WSTRTOS_incrementRxfTicks()
which allows the schedular in the OO RTX to see if timeout events must
be sent to objects in your Rhapsody model. Obviously, when you program
a tm( 10 ) in your UML model, you want this timout event to occur after
10 msec, so you must understand and maybe modify the relation between
the timer interrupt frequency and the scheduling of timeout events..
Your target will impose some limits, some processors have a smaller
interrupt latency than others:
- when, in a statechart, you write tm( 1 ) you would expect
Rhapsody to take the transition after a 1ms delay. Alas, this is not
always true. It depends on the possible granularity of the
timer.
On a Windows system the timer granularity is set to 100ms because a PC
is simply not capable of reacting much faster (*1). This means that it
does not matter if you write tm( 1 ), tm( 2 ), .... or tm( 100 ), they
will all give you a 100ms delay.
- in most 16-bit CPU's, setting the timer very fast results
in a
performance degradation. On a 10 Mhz CPU, serving an interrupt every
1ms is a heavy burden on the system. If you want faster or more precise
timers, use hardware timers, mask them with objects and then you can be
as fast as you want.
Tick Timer Granularity
If we have a system tick of say
20ms and we ask for a timeout of 65ms, then the resulting timeout will
actually be between 80ms and 100ms, depending on when the timeout is
started relative
to the system tick.

If precise
timeouts are required, then it is recommended to use a hardware timer
in combination with triggered operations.
The framework internally manages
the timeout value resulting from an tm(xx) transition using an timeUnit
data type. Depending on its size, this type imposes limits for a timeout value.
You need to verify the timer initialization code is appropriate for
your target derivate and configuration. Please refer to the
implementation of your target bridge, specifically the implementation
of the function WSTTarget_Init()
in WSTTarget.c,
WSTRTOS_Init() in WSTRTOS.c
and the constant RIC_MS_PER_TICK
in WSTRTOS.h.
Copyright (c) Willert
Software Tools GmbH. All rights reserved.