271/317
9 - A Carrier-current System for domestIc Remote Control
if ( Second > 50 )
/* The display blinks at 1 Hz with a short duty
cycle. */
PADR = DISPLAY_OFF ;
/* Switch LED off. */
else
PADR = SevenSegment[Delay][Second & 1] ;
/* Light one of
both digits at a time. */
Since second ranges from 63 to zero, the display is lit 23/64 of the time every second.
The remainder of the code of the whole interrupt routine merely maintains the counters that
count 64 interrupts to make one second, then 3600 seconds to make one hour, then from 0 to
15 full hours. W hen the delay has elapsed, the CLOSE command is sent and the display is
switched off.
The code is the following:
#pragma TRAP_PROC SAVE_REGS
void DelayCounter ( void )
{
WDGR = 0xFF ;
/* reload watchdog */
asm
{
ld a, TBSR ;
ld a, TBCLR ;
/* Dummy read to clear interrupt request */
}
if ( Delay == 0 )
PADR = DISPLAY_OFF ;
/* Switch LED off. */
else
{
if ( Second > 50 )
/* The display blinks at 1 Hz with a short
duty cycle. */
PADR = DISPLAY_OFF ;
/* Switch LED off. */
else
PADR = SevenSegment[Delay][Second & 1] ;
/* Light one of
both digits at a time. */
if ( Second == 0 )
{
Second = 63 ;
/* One second is elapsed: reload counter. */
if ( Hour == 0 )
{
Hour = 3600 ;
/* One hour is elapsed: reload counter. */
if ( Delay == 1 )
/* Last hour finished ? */
SendCommand ( CLOSE_COMMAND ) ; /* Close now. */
Delay-- ;
/* Decrement anyway ; if 1, set to zero,
and terminate delay. */
}
else
Hour-- ;
}
else
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 ...