Page 139 - Embedded Microprocessor Systems Real World Design
P. 139
Sometimes called an idle loop, superloop, or background loop, the polling loop is where
the software spends its time when not processing interrupts. The polling loop
determines how the various tasks are scheduled and executed. While everything in
an embedded system usually works in real time, the polling loop holds those tasks
that do not need immediate attention. An example of this in the pool timer is the
code to handle the push buttons. The timer code tells the polling loop when
the button is pressed. The polling loop may be slow getting to it, but not slow
enough for the user to notice. In a completely interruptdriven system, the polling
loop may be a one-instruction jump to itself. (I did this once with a digital signal
processor [DSP] design.) But in most systems, the polling code does some actual
processing.
The pool timer polling loop continuously checks these processes:
The motor control code, which handles motor on/off control.
The powerfail code, which blinks the display after power-up until the user presses
the SET button.
The normal timekeeping code, which keeps track of when the time changes from
ON to OFF and handles on/off/override.
The time set mode, which allows a new ON or OFF time to be entered.
The polling loop sequentially checks for each event (timeout, button press, and
so on) and takes the necessary action.
Data Flow Diagram
There are a number of ways to describe the software design, depending on what
information is to be conveyed. One method is a dataflow diagram. The data flow
diagram shows each process as a block (or circle). Lines connect the blocks,
showing what information is passed between the processes.
Figure 4.1 shows a data flow diagram for the pool timer. The timer interrupt
tells the motor control code if the water level is low and tells the other three
processes if the SET button is pressed. The time set code passes updated time back
to the normal timekeeping code so that time rollovers will result in the correct
initial time. The other paths can be seen on the diagram. This diagram shows the
most important data items; a complete diagram could be drawn that shows every
flag and data byte.
Data passed to and from the hardware is not shown in this figure. If it did, a box
would represent the keypad with push-button information going into the interrupt
code and another box would represent the display accepting time data from the
interrupt code. Some engineers draw the hardware as just another process; others
denote it with a special symbol.
120 Embedded Microprocessor Systems