270/317
9 - A Carrier-current System for domestIc Remote Control
The interrupts are triggered by an overflow of the free-running counter. At each interrupt, the
PA7 bit is toggled, so that each digit is lit every other interrupt, that is, there are 32 refresh cy-
cles per second.
Since the values to be displayed range from zero to 15, driving of the display could be per-
formed easily using the following arrangement:
The various patterns that make up the display are stored in a constant two-dimensional array,
with 15 rows of 2 elements. Each couple corresponds to a value to be displayed; each element
of a couple is one of the two values that must be written to PA, alternately, so that the display
is both chopped and updated in such a way that it looks like a steady two digit display.
The constant array is defined as follows:
const Byte SevenSegment[16][2] = {
{0xff, 0x84}, {0xff, 0xed}, {0xff, 0xa2}, {0xff, 0xa8}, /*
0-3 */
{0xff, 0xc9}, {0xff, 0x98}, {0xff, 0x90}, {0xff, 0xad}, /*
4-7 */
{0xff, 0x80}, {0xff, 0x88}, {0x6d, 0x84}, {0x6d, 0xed}, /*
8-11 */
{0x6d, 0xa2}, {0x6d, 0xa8}, {0x6d, 0xc9}, {0x6d, 0x98}
/*
12-15 */
} ;
This constant table is located in ROM (or program segment) by means of the
const
modifier,
and the
-Cc
compiler option added in the
Compoptions
item of the environment file. The same
way, the
Codes[]
table mentioned earlier is defined as follows:
const Byte Codes[] = {6, 7, 4, 5, 8, 9, 10, 11, 14, 15, 12, 13, 0, 1, 2, 3,
16, 24, 20, 28, 18, 26, 22, 30, 17, 25, 21, 19,
27, 23, 31} ;
Updating the display is done easily using the following statement, where
Delay
contains the
number to display, and
Second
is decremented at each interrupt:
PADR = SevenSegment[Delay][Second & 1] ;
/* Light one of both digits
at a time. */
When the delay reaches zero, the display is switched off by merely writing 0xff to it. This also
causes the display to blink at the rate of once per second:
Содержание 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 ...