EasyManua.ls Logo

ST ST7 - Page 271

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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. When the delay has elapsed, the CLOSE command is sent and the display is
switched off.
Thecodeisthefollowing:
#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-- ;

Table of Contents

Related product manuals