212/317
7 - Debugger and PROM Programmer Tutorial for ST72251
Multitsk.bat
, that is the batch file that does the linking and the back-annotation.
Here are details on each of these.
7.6.4.1 Main file
(Multitsk.asm)
The main file contains the code for the initialization of the system, that is terminated by a call
to
StartTasks
. As explained earlier, this call does not return; so it is not surprising that the
code is not continued there.
The timer interrupt service routine decrements by one each of the four counters
Reg1
to
Reg4
.
These are used in the body of the tasks to perform the timing.
As said earlier, this application has four identical tasks. To emphasize this, the body of the
tasks is written as a macro, that is expanded four times, once for each task. The macro has
one parameter that is the task number; for the only differences between the tasks are the an-
alog channel used, the bit of port A that is toggled, and the timing register used. The body of
the tasks is an infinite loop. The result of the analog to digital conversion is retrieved, then con-
verted using the lookup table defined in this file. The number found in the table is written to the
timing register,
Regn
, where
n
is the task number. Then there is a loop that decrements
Regn
and calls
Yield
. This loop is only exited when the count has reached zero; then the corre-
sponding bit of port A is toggled, and the endless loop resumes.
This algorithm is a very typical algorithm that could be written the same way if it were the only
task that the microcontroller has to do. Here, there are four such tasks running simultaneously,
but they all use this same algorithm. The trick is the use of the
Yield
subroutine in the wait
loop. For each task, this subroutine is a “do nothing” routine. Actually, it does not alter anything
within the current task. But it is while this subroutine executes that the other tasks are given
control; and when they release it, the current task regains it.
Here is the power of a multitasking kernel: each task is written as though it were running alone
in the system, but by inserting a call to a magic subroutine at the appropriate places, this al-
lows the core to also run the other tasks, although no special precautions related to the other
tasks are taken by the current task.
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...