?? hwgyjnkg.asm
字號:
;***************************************************************************
;* ********************************* *
;* * W N - 1 0 0 F I R M W A R E * *
;* ********************************* *
;***************************************************************************
;
; Written for The Watt Stopper, Inc. by
; Power Innovations, Inc., Los Gatos, CA 95030, USA
;
; Last Edit: 19 March 2004 by RRB
;
.equ MAJOR = 0
.equ MINOR = 7
;
;--------------------------------------------------------------------------;
; Copyright (c) 2002-2004 by ;
; The Watt Stopper, Inc., Santa Clara, CA., USA ;
; All Rights Reserved. Unpublished rights reserved under the ;
; copyright laws of the United States. ;
; ;
; The software contained on this media is proprietary to and embodies the;
; confidential technology of The Watt Stopper, Inc. Possession, use, dupli-;
; cation or dissemination of the software and media is authorized only ;
; pursuant to a valid written license from The Watt Stopper, Inc. ;
; ;
; This software is furnished under a license and may be used and copied;
; only in accordance with the terms of such license and with the inclusion;
; of the above copyright notice. This software or any other copies thereof;
; may not be provided or otherwise made available to any other person. No;
; title to and ownership of the software is hereby transferred. ;
; ;
; The information in this software is subject to change without notice and;
; should not be construed as a commitment by The Watt Stopper, Inc. ;
; ;
; The Watt Stopper, Inc. assumes no responsibility for the use or ;
; reliability of its software on equipment which is not supplied by ;
; The Watt Stopper, Inc. ;
; ;
; RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the U.S.;
; Government is subject to restrictions as set forth in Subparagraph;
; (c)(1)(ii) of DFARS 252.227-7013, or in FAR 52.227-19, as applicable. ;
;--------------------------------------------------------------------------;
;
; Revision History:
; ----------------
;
; R0.1 10-APR-02 RRB Initial implementation.
; R0.2 19-JUN-02 RRB Full implementation of initial specification.
; R0.3 17-JUL-02 RRB Correct adaptation of relay timing on opening;
; add manufacturing diagnostics on initial power-up.
; R0.4 24-SEP-02 RRB Improve noise rejection on zero-cross; correct double-
; counting of line cycles introduced in R0.3.
; R0.5 22-NOV-02 RRB Correct error in test mode cancellation timeout.
; R0.6 25-FEB-04 RRB Correct relay timing determination for opening.
; R0.7 19-MAR-04 RRB Widen test window for line cycle length, to simplify
; testing in China; make test for entry to manufacturing
; test mode more robust.
;
;--------------------------------------------------------------------------
; Definitions for ATtiny15 processor (include file not yet available from
; Atmel at this time):
;
;***** Specify Device
.device ATtiny15
;***** I/O Register Definitions
.equ SREG =$3f
.equ GIMSK =$3b
.equ GIFR =$3a
.equ TIMSK =$39
.equ TIFR =$38
.equ MCUCR =$35
.equ MCUSR =$34
.equ TCCR0 =$33
.equ TCNT0 =$32
.equ OSCCAL =$31
.equ TCCR1 =$30
.equ TCNT1 =$2f
.equ OCR1A =$2e
.equ OCR1B =$2d
.equ SFIOR =$2c
.equ WDTCR =$21
.equ EEAR =$1e
.equ EEDR =$1d
.equ EECR =$1c
.equ PORTB =$18
.equ DDRB =$17
.equ PINB =$16
.equ ACSR =$08
.equ ADMUX =$07
.equ ADCSR =$06
.equ ADCH =$05
.equ ADCL =$04
;***** Bit Definitions
.equ INT0 =6
.equ PCIE =5
.equ INTF0 =6
.equ PCIF =5
.equ OCIE1 =6
.equ TOIE1 =2
.equ TOIE0 =1
.equ OCF1 =6
.equ TOV1 =2
.equ TOV0 =1
.equ PUD =6
.equ SE =5
.equ SM1 =4
.equ SM0 =3
.equ ISC01 =1
.equ ISC00 =0
.equ WDRF =3
.equ BORF =2
.equ EXTRF =1
.equ PORF =0
.equ CS02 =2
.equ CS01 =1
.equ CS00 =0
.equ CTC1 =7
.equ PWM1 =6
.equ COM11 =5
.equ COM10 =4
.equ CS13 =3
.equ CS12 =2
.equ CS11 =1
.equ CS10 =0
.equ FOC1A =2
.equ PSR1 =1
.equ PSR0 =0
.equ WDTOE =4
.equ WDE =3
.equ WDP2 =2
.equ WDP1 =1
.equ WDP0 =0
.equ EEIE =3
.equ EEMWE =2
.equ EEWE =1
.equ EERE =0
.equ ACD =7
.equ GREF =6
.equ ACO =5
.equ ACI =4
.equ ACIE =3
.equ ACIS1 =1
.equ ACIS0 =0
.equ REFS1 =7
.equ REFS0 =6
.equ ADLAR =5
.equ MUX2 =2
.equ MUX1 =1
.equ MUX0 =0
.equ ADEN =7
.equ ADSC =6
.equ ADFR =5
.equ ADIF =4
.equ ADIE =3
.equ ADPS2 =2
.equ ADPS1 =1
.equ ADPS0 =0
.def ZL =r30
.def ZH =r31
;------ Documentation Conventions --------------------------------------;
;
; The following commenting conventions are observed in this source file:
;
; If an instruction has been eliminated to save space, because it would
; effectively be a "no operation" (for example, if it would be a jump to
; the next addressable location), the assembly line is preserved, but is
; prefixed with the sequence ";==" to prevent its actual compilation.
;
; Comments on any instructions that *always* are executed with interrupts
; disabled are prefixed with ";***".
;
;---------------------- Operating Mode Variations ----------------------;
; ;
; Those characteristics that distinguish the different ;
; modes are defined here, and are selected in the SETUP ;
; menu by the installer/user. ;
;-----------------------------------------------------------------------;
;
; Mode 1: One Hour, Manual On (Factory Default)
;
.equ MODE1 = 0
.equ M1_TIMEOUT = ((60*60*60)>>4) ;Timeout = 60 minutes
;
; Mode 2: Two Hours, Manual On
;
.equ MODE2 = 1
.equ M2_TIMEOUT = ((120*60*60)>>4) ;Timeout = 120 minutes
;
; Mode 3: Thirty Minutes, Manual On
;
.equ MODE3 = 2
.equ M3_TIMEOUT = ((30*60*60)>>4) ;Timeout = 30 minutes
;
; Mode 4: Fifteen Minutes, Manual On
;
.equ MODE4 = 3
.equ M4_TIMEOUT = ((15*60*60)>>4) ;Timeout = 15 minutes
;
; Mode 5: Fifteen Minutes, Auto On
;
.equ MODE5 = 4
.equ M5_TIMEOUT = ((15*60*60)>>4) ;Timeout = 15 minutes
;
.equ MAX_MODE = 4 ;Highest internal mode number assigned
;
; Test Mode: Fifteen Seconds, Auto On
;
.equ TM_TIMEOUT = ((15*60)>>4) ;Timeout = 15 seconds
;
; NightLight Timeout: Ninety Seconds
;
.equ NL_TIMEOUT = ((90*60)>>8) ;Timeout = 90 seconds
;
; NightLight Disable Timeout: 48 hours
;
.equ NL_DISABLE = ((48*60*60*60)>>8)
;
; Test Mode Cancellation Timeout
;
.equ TM_CANCEL_TIMEOUT = ((5*60*60)>>8) ;Timeout = 5 minutes
;
; Auto-On Cancellation Timeout
;
.equ TM_AUTO = ((30*60)>>4) ;Cancel Auto-On after 30 seconds of vacancy
;
;------ Button/Mode Switch/Light Sensor Demux ----------;
; ;
; The front panel pushbutton, program mode slide switch ;
; and light sensor (CdS) all share a single ADC input, ;
; therefore, the voltage on that input is interpreted ;
; to decode the various states. ;
;-------------------------------------------------------;
;
; Values between $00 and $07 indicate that the button is pressed.
;
.equ ADC_BUTTON_MAX = $07
;
; Values between $08 and $C0 indicate a valid light level from the
; CdS sensor, and that the local button is not pressed, and the
; mode switch is in NORMAL, not PROGRAM, mode.
;
.equ ADC_CDS_MAX = $C0
;
; Values between $C1 and $D8 indicate that the mode switch is in the
; NORMAL mode, no CdS sensor is present, and the front panel button
; is not pressed.
;
.equ ADC_PGOFF_MAX = $D8
;
; Values between $D9 and $FF indicate that the mode switch is in the
; PROGRAM mode, and the front panel button is not pressed.
;
.equ ADC_PGON_MAX = $FF
;
;------ I/O Bit Assignments in Port B ------------------;
;
.equ fRelayOn = 0 ;Load relay ON if high (Output)
.equ fZeroCross = 1 ;Zero-cross sense (Input)
.equ fNightLight = 2 ;NightLight ON if high (Output)
.equ fLowLight = 3 ;Light level below 13fc if high (Input)
.equ fRelaySense = 4 ;Relay closure sense (Input)
.equ fOccupancy = 5 ;Occupancy sensor waveform (Input)
;
.equ PORTB_INIT = $00 ;Input pullups to enable by default
.equ DDRB_INIT = $05 ;Input/Output defaults
;
;------ Control Register Setup Constants ---------------;
;
.equ WDTCR_INIT = $0B ;Watchdog enabled, timeout in 128K cycles (~ 0.374 sec)
.equ TCCR1_INIT = $0C ;Timer/Counter1 enabled, at CK/128 - this rate is
;chosen so that one AC line cycle (at 60Hz) is
;less than 256 counts, at a clock frequency of 1.6MHz
.equ ADMUX_OCCUP = $00 ;ADC select channel ADC0=PB5 (occupancy)
.equ ADMUX_LIGHT = $22 ;ADC left-adjust result, select ADC2=PB3 (light)
.equ ADCSR_INIT = $93 ;ADC enable, clear IF, use CK/8 as clock source
.equ ADCSR_OFF = $13 ;ADC disable, clear IF, use CK/8 as clock source
;
;----- Register Assignments -----
;
.def result = r0 ;Receives table lookup bytes (LPM)
.def zero = r1 ;Handy register guaranteed to be zero contents
.def lineCycles = r2 ;Counts up once/line cycle; used to provide programmable
; delays for other events (diagnostic output, timeouts)
.def mode = r3 ;In Setup, index of presently-selected operating mode
.def onDelay = r4 ;Delay, in Timer1 ticks, for turning on relay
.def offDelay = r5 ;Delay, in Timer1 ticks, for turning off relay
.def nightLightDisableL = r6 ;Time, in 4.27S units, until nightlight operation is again
.def nightLightDisableH = r7 ; enabled (nightlight is enabled if == 0)
.def testModeTimer = r8 ;If <> 0, time, in 4.27S units, until Test Mode cancels
.def lastSample = r9 ;Last sample from PIR
.def maxNoise = r10 ;Peak value seen on occupancy sensor in last 4.27 seconds,
; updated if area is presently vacant
.def noiseL = r11 ;Time average of peak noise seen on occupancy sensor
.def noiseM = r12 ; input in last 256x256x256 line cycles (approx. 3.24 days)
.def noiseH = r13 ;
.def flashPatternL = r14 ;NightLight flash pattern for Program mode; 1 indicates LED
.def flashPatternH = r15 ; on for 0.27S, 0 indicates off; repeats every 4.27S
;
;----
;
.def temp0 = r16 ;General purpose temporary
.def temp1 = r17 ;General purpose temporary
.def temp2 = r18 ;General purpose temporary
.def holdCounter = r19 ;Time, in 1/60ths of a sec, that button has been held down
.def button = r20 ;Front panel button history
.def status = r21 ;Internal operating status
.def occupTimerL = r22 ;Zero if vacant, else the count of 16-line-cycle units
.def occupTimerH = r23 ; until vacancy should be declared
.def vacantTimer = r24 ;Zero if occupied, else # of 16-line-cycle units since vacant
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -