⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dingshikaishui.dt

📁 采用义隆EM78P468单片机做的定时灌溉花园的程序.通过了测试,并已经用在实际的产品中.
💻 DT
📖 第 1 页 / 共 5 页
字号:
;***************************************************************;
; C0MPANY NAME	:	Automatic Manufacturing Limited		;
; CUSTOMER	:	wait define				;
; Project Name	:	Water Computer				;
; Project No.	:	1080C					;
; AUTHOR NAME	:	Zoubh			;
; Creat Data	:	June 12, 2008				;
; Finish Data	:	Nc					;
; Version No.	:	V3.7					;
; MCU TYPE	:	EM78P468L				;
;***************************************************************;
;EM78P468L drive LCD, Fmain: RC[51k], Fsub: crystal(32768Hz)	;
;***************************************************************;
; 17-10-2007   	ZouBH	First full feature release		;
; 23-10-2007	ZouBH	Fix standby power issue. (< 10uA)	;
; 25-10-2007	zoubh	1> relax key return auto mode from 15s	;
;			   to 1 min				;
;			2> fix the 1st schedule [option:12]	;
;			3> fix the knock key system crash/hang	;
;			4> per 10 minutes check low battery	;
; 26-10-2007	zoubh	1> fix the last schedule adjust		;
;			2> fix quick mode decrease minute	;
;			   function				;
;			3> fix time mode up/down week display	;
;			4> fix keep press key function		;
;			5> fix battery check and battery display;
; 27-10-2007	zoubh	1> fix power off function		;
;			2> adjust rom space			;
; 30-10-2007	zoubh	1> fix [auto mode] schedule & relax key	;
;			   relate function			;
;			2> fix after 1 min, from Quick mode	;
;			   return auto mode function		;
;			3> fix quick and forbit mode minute fun	;
; 01-11-2007	zoubh	1> fix time mode "enter" function	;
;			2> fix the last schedule put in function;
; 02-11-2007	zoubh	1> fix "PO" clock function (wait finish);
;								;
; 06-11-2007	zouBH	Added overnight schedule handling	;
;			but the overlap scheduling method goes 	;
;			one by one				;
;								;
; 08-11-2007	zouBH	1)Added battery calibration in test mode;
;			2)Modify the low batt handle when start	;
;			to water while low battery.		;
;			3)Correct the 0:00 not watering issue.	;
;								;
; 09-11-2007	zouBH	1) Correct the wrong watering day issue ;
;			when the user input schedule with C	;
;			and after that change the date in Time	;
;			mode					;
; 			2) Fix the low voltage issue. The low	;
;			   voltage indicator will not change 	;
;			   state even if the voltage is good. 	;
;			   This state can be clear only when	;
;			   PO is occured and the new battery is	;
;			   good.				;
; 10-11-2007	ZouBH	1) Under Forbid mode and enter Quick mod;
;			   When start to water at 2 min or more	;
;			   The system will turn back to OFF 	;
;			   after 1 min without taking care the 	;
;			   water stop time, this issue is fixed	;
;			2) At the end of watering, the next over;
;			   -lapping schedule with longest close	;
;			   water time is selected to be executed;
;			   This matches the original 080C device; 
;								;
; 13-11-2007	ZouBH	1) Fix schedule issue when setting sch	;
;			   cycle to "1".			;
;			2) If pressing no key under program mode;
;			   system enter Auto mode after 1 min,	;
;			   but the schdule record will lost.This;
;			   will not happen if pressing Menu key	;
;			   to leave program mode.(issue fix now);
;								;
; 24-11-2007(v1e) zouBH	1) Fix PO issue under normal watering 	;
;			   schedule(watering state )		;
;			2) Fix low battery icon issue in test 	;
;			   mode.				;
;			3) Fix time mode display error if at 	;
;			   first powerup, the motor position is	;
;			   not correct.				;
;			4) Fix under 12 schedule and 23:59,	;
;			   system reset issue.			;
;			5) Fix water time inc by 5 just after	;
;			   key hold issue.			;
;			6) Fix in test mode, if watering time is;
;			   9s, 10s, motor wrong activity issue  ;
;			7) key debounce time set to 1/8 sec no	;
;			   longer 1/4 sec, increase sensitivity ;
; 								;
; 2-12-2007(v1F)	1) Fix 12 schedule reset issues again.	;
;			2) Fix 40% or less watering percentage	;
;			   that triggers 0 water time issue.	;
;			3) Fix pressing M key back to auto mode ;
;			   from forbid mode issue.		;
;								;
; 8-12-2007 (V2.0)	disable 0.5 sec motor detect.		;
;								;
; 10-12-2007 (V2.01)	re-enable the 0.5s motor pos detect.	;
;								;
; 14-12-2007 (V2.22)    1) Added debounce handling in motor pos	;
;			   detection.				;
;			2) Disable key int during motor run	;
;								;
; 19-12-2007 (V2.3)     Enhance rain sensor function.		;
;								;
; 21-12-2007 (v2.4)     1)Fix rain sensor function. The rain 	;
;			sensor is checked every 10 min.		;
;			2) fix PO minor issue under forbid mode ;
;								;
; 10-01-2008 (V2.5)	12 schedule makes system reset issue	;
;			(fix1)					;
;								;
; 20-01-2008 (V2.6) 	12 schedule makes system reset issue	;
;			(fix 2)					;
;								;
; 28-01-2008 (V2.7)     enhance motor position checking method 	;
;			such that motor double turns is improved;
;								;
; 13-02-2008 (v2.8)	fix during rain, program mode cannot set;
;			watering day at "C" watering pattern.	;
;			Added main loop motor pos detect	;
; 13-03-2008 (V2.9)	During watering->low battery->PowerOff	;
;			-->resme power, system now will close	;
;			water and locked in the low batt state	;
;								;
; 30-05-2008 (V3.1)Fix the reset issue due to holding the motor.
;
; 11-06-2008 V3.3 Fix reset and hold key issue.
; 
; 11-06-2008 V3.4 Fix holding motor and close water issue 
; 
; 12-06-2008 V3.5 Add to check option set for determining motor reset err
;
; 10-07-2008 V3.6 Add nops after sleep to extent the 32k clock warmup time.
;
; 19-07-2008 V3.7 Add the version display in test mode, battery test.
; 		          Display version number in test mode;
;                 Alter some number in subroutine LightRow2 if update the version number
;***************************************************************;
; Operational Registers Define				;
;======================================================;
;
;======================================================;
; Register R0~RF					;
;======================================================;
; 
; Indirect Addressing register
; 
 R0	==	0x00
 IAR	==	0x00
; 
; Time Clock/Counter
; 
 R1	==	0x01
 TCC	==	0x01		; TCC Counter Preset
;
; Program Counter
; 
 R2	==	0X02
 PC	==	0X02
;
; Status Register and ROM Page Select Register
; 
 R3	==	0X03
 SR	==	0X03
;
     ;{
	 PS1	==	0x06	; Page Select Bit[1]
	 PS0	==	0x05	; Page Select Bit[0]
				;
				; |-----|-----|-----------------------------|
				; | PS1 | PS0 | Program ROM Page and Address|
				; |-----|-----|-----------------------------|
				; |  0  |  0  |     Page 0 (0x000~0x3FF)    |
				; |  0  |  1  |     Page 1 (0x400~0x7FF)    |
				; |  1  |  0  |     Page 2 (0x800~0xBFF)    |
				; |  1  |  1  |     Page 3 (0xC00~0xFFF)    |
				; |-----|-----|-----------------------------|
				;
	T	==	0x04	; Time-Out Bit
	P	==	0x03	; Power Down Bit
	Z	==	0x02	; Zero Flag
	DC	==	0x01	; Auxiliary Carry Flag
	C	==	0x00	; Carry Flag
				;
	mPS1	==	0x40	; Page Select Bit[1]
	mPS0	==	0x20	; Page Select Bit[0]
	mT	==	0x10	; Time-Out Bit
	mP	==	0x08	; Power Down Bit
	mZ	==	0x04	; Zero Flag
	mDC	==	0x02	; Auxiliary Carry Flag
	mC	==	0x01	; Carry Flag
				;
	; Example
	; choose Page 2
	; method 1	
	;   {
	;	MOV  A,@(mPS1)
	;	MOV  SR,A
	;   }
	; method 2
	;   {
	;	BS  SR,PS1
	;	BC  SR,PS0 
	;   }
     ;}
; 
; RAM Select Register (RSR)
; 
 R4	==	0X04
 RSR	==	0X04
     ;{				; Bits 7~6 are determoned the R20~R3F which bank is active
				; Bits 5~0 are used to select registers(address: 00~3F)
				; in the indirect addressing mode
				;
	RBS1	==	0x07	; R20~R3F ram bank select bit
	RBS0	==	0x06	; it can using "bank" instruction to set these bits.
				;
	RSR5	==	0x05	;
	RSR4	==	0x04	;
	RSR3	==	0x03	;
	RSR2	==	0x02	;
	RSR1	==	0x01	;
	RSR0	==	0x00	;
				;
	mRBS1	==	0x80	; R20~R3F ram bank select bit
	mRBS0	==	0x40	; it can using "bank" instruction to set these bits.
				;
	mRSR5	==	0x20	;
	mRSR4	==	0x10	;
	mRSR3	==	0x08	;
	mRSR2	==	0x04	;
	mRSR1	==	0x02	;
	mRSR0	==	0x01	;
     ;}
;
; Port 5 data and IOC Page Select Register
;
 R5	==	0X05
 PORT5	==	0X05
; 
     ;{
	R57	==	0x07	; I/O data of P5.7
	R56	==	0x06	; I/O data of P5.6
	R55	==	0x05	; I/O data of P5.5
	R54	==	0x04	; I/O data of P5.4
				; bits 3~1 not use 
	IOCPAGE	==	0x00	; IOC5~IOCF Page Select Bit.
				; "0" : Page0 -> Select IOC50~IOCF0
				; "1" : Page1 -> Select IOC61~IOCE1
				;
	mR57	==	0x80	; I/O data of P5.7
	mR56	==	0x40	; I/O data of P5.6
	mR55	==	0x20	; I/O data of P5.5
	mR54	==	0x10	; I/O data of P5.4
				; bits 3~1 not use 
	mIOCPAGE==	0x01	; IOC5~IOCF Page Select Bit.
				; "0" : Page0 -> Select IOC50~IOCF0
				; "1" : Page1 -> Select IOC61~IOCE1
     ;}
; 
; Port 6 data Register
; 
 R6	==	0X06
 PORT6	==	0X06
;
     ;{
	R67	==	0x07	; I/O data of P6.7
	R66	==	0x06	; I/O data of P6.6
	R65	==	0x05	; I/O data of P6.5
	R64	==	0x04	; I/O data of P6.4
	R63	==	0x03	; I/O data of P6.3
	R62	==	0x02	; I/O data of P6.2
	R61	==	0x01	; I/O data of P6.1
	R60	==	0x00	; I/O data of P6.0
				;
	mR67	==	0x80	; I/O data of P6.7
	mR66	==	0x40	; I/O data of P6.6
	mR65	==	0x20	; I/O data of P6.5
	mR64	==	0x10	; I/O data of P6.4
	mR63	==	0x08	; I/O data of P6.3
	mR62	==	0x04	; I/O data of P6.2
	mR61	==	0x02	; I/O data of P6.1
	mR60	==	0x01	; I/O data of P6.0
     ;}
; 
; Port 7 data Register
; 
 R7	==	0X07
 PORT7	==	0X07
;
     ;{
	R77	==	0x07	; I/O data of P7.7
	R76	==	0x06	; I/O data of P7.6
	R75	==	0x05	; I/O data of P7.5
	R74	==	0x04	; I/O data of P7.4
	R73	==	0x03	; I/O data of P7.3
	R72	==	0x02	; I/O data of P7.2
	R71	==	0x01	; I/O data of P7.1
	R70	==	0x00	; I/O data of P7.0
				;
	mR77	==	0x80	; I/O data of P7.7
	mR76	==	0x40	; I/O data of P7.6
	mR75	==	0x20	; I/O data of P7.5
	mR74	==	0x10	; I/O data of P7.4
	mR73	==	0x08	; I/O data of P7.3
	mR72	==	0x04	; I/O data of P7.2
	mR71	==	0x02	; I/O data of P7.1
	mR70	==	0x01	; I/O data of P7.0
     ;}
;  
; Port 8 data Register
; 
 R8	==	0X08
 PORT8	==	0X08
;
     ;{
	R87	==	0x07	; I/O data of P8.7
	R86	==	0x06	; I/O data of P8.6
	R85	==	0x05	; I/O data of P8.5
	R84	==	0x04	; I/O data of P8.4
	R83	==	0x03	; I/O data of P8.3
	R82	==	0x02	; I/O data of P8.2
	R81	==	0x01	; I/O data of P8.1
	R80	==	0x00	; I/O data of P8.0
				;
	mR87	==	0x80	; I/O data of P8.7
	mR86	==	0x40	; I/O data of P8.6
	mR85	==	0x20	; I/O data of P8.5
	mR84	==	0x10	; I/O data of P8.4
	mR83	==	0x08	; I/O data of P8.3
	mR82	==	0x04	; I/O data of P8.2
	mR81	==	0x02	; I/O data of P8.1
	mR80	==	0x01	; I/O data of P8.0
     ;}
;  
; LCD Control Register
;
 R9	==	0X09
 LCDCR	==	0X09
;
     ;{
	LBS	==	0x07	; LCD Bias Select Bit."0":1/2 Bias,"1":1/3 Bias
	DS1	==	0x06	; LCD Duty Select Bit[1]
	DS0	==	0x05	; LCD Duty Select Bit[0]
				;
				; |-----|-----|----------|
				; | DS1 | DS0 | LCD Duty |
				; |-----|-----|----------|
				; |  0  |  0  | 1/2 Duty |
				; |  0  |  1  | 1/3 Duty |
				; |  1  |  X  | 1/4 Duty |
				; |-----|-----|----------|
				; bit 5 not use
	LCDEN	==	0x04	; LCD Enable Bit."0":Disable,"1":Enable
	LCDTYPE	==	0x02	; LCD Drive Waveform Select Bit
				; "0" : A Type Waveform,
				; "1" : B Type Waveform
	LCDF1	==	0x01	; LCD Frame Frequency Control Bit[1]
	LCDF0	==	0x00	; LCD Frame Frequency Control Bit[0]
				;
				; |-----|-----|------------------------|----|
				; |     |     |   LCD Frame Frequency  |    |
				; |LCDF1|LCDF0|------------------------|Unit|
				; |     |     |1/2 Duty|1/3Duty|1/4Duty|    |
				; |-----|-----|--------|-------|-------|----|
				; |  0  |  0  |  64.0  |  63.5 |  64.0 | Hz |
				; |  0  |  1  |  58.5  |  58.0 |  58.5 | Hz |
				; |  1  |  0  |  53.9  |  53.5 |  53.9 | Hz |
				; |  1  |  1  |  70.6  |  70.0 |  70.6 | Hz |
				; |-----|-----|--------|-------|-------|----|
				;
	mLBS	==	0x80	; LCD Bias Select Bit 
	mDS1	==	0x40	; LCD Duty Select Bit[1]
	mDS0	==	0x20	; LCD Duty Select Bit[0]
	mLCDEN	==	0x10	; LCD Enable Bit
				; bit 5 not use
	mLCDTYPE==	0x04	; LCD Drive Waveform Select Bit
	mLCDF1	==	0x02	; LCD Frame Frequency Control Bit[1]
	mLCDF0	==	0x01	; LCD Frame Frequency Control Bit[0]
     ;}
; 
; LCD RAM Address
;
 RA	==	0X0A
 LCD_ADDR==	0X0A
 LCDAR	==	0x0a
;
; LCD Data Buffer
;
 RB	==	0X0B
 LCD_DB	==	0X0B
 LCDBR	==	0x0B
;
; Counter/Timer Enable Register 
;
 RC	==	0X0C
 CNTER	==	0X0C
;
     ;{
				; bit 7~4 not use
	LPWTEN	==	0x03	; LPWT Enable Bit
				; "0" : Disable
				; "1" : Enable
	HPWTEN	==	0x02	; HPWT Enable Bit
				; "0" : Disable
				; "1" : Enable
	CNT2EN	==	0x01	; Counter 2 Enable Bit
				; "0" : Disable
				; "1" : Enable
	CNT1EN	==	0x00	; Counter 1 Enable Bit
				; "0" : Disable
				; "1" : Enable
				;
				; bit 7~4 not use
	mLPWTEN	==	0x08	; LPWT Enable Bit
	mHPWTEN	==	0x04	; HPWT Enable Bit
	mCNT2EN	==	0x02	; Counter 2 Enable Bit
	mCNT1EN	==	0x01	; Counter 1 Enable Bit
      ;}
; 
; System Clock, Booster Frequency and PLL Frequency Control Register
;
 RD	==	0X0D
 SBPCR	==	0X0D
;
     ;{
				; bit 7 not use
	CLK2	==	0x06	; Main Clock Select Bit[2] for PLL Mode
	CLK1	==	0x05	; Main Clock Select Bit[1] for PLL Mode
	CLK0	==	0x04	; Main Clock Select Bit[0] for PLL Mode
				;
				; |-----|-----|-----|----------|
				; |CLK2 |CLK1 |CLK0 | PLL FREQ |
				; |-----|-----|-----|----------|
				; |  0  |  0  |  0  | 4.260 MHz|
				; |  0  |  0  |  1  | 2.130 MHz|
				; |  0  |  1  |  0  | 1.065 MHz|
				; |  0  |  1  |  1  | 532.5 KHz|
				; |  1  |  X  |  X  | 8.000 MHz|
				; |-----|-----|-----|----------|
				;
	IDLE	==	0x03	; IDLE Mode Select Bit
				; "0"+SLEP -> Sleep Mode
				; "1"+SLEP -> IDLE Mode
	BF1	==	0x02	; LCD Booster Frequency Select Bit[1]
	BF0	==	0x01	; LCD Booster Frequency Select Bit[0]
				;
				; |-----|-----|------------|
				; | BF1 | BF0 |BOOSTER FREQ|
				; |-----|-----|------------|
				; |  0  |  0  |    FS      |
				; |  0  |  1  |    FS/4    |
				; |  1  |  0  |    FS/8    |
				; |  1  |  1  |    FS/16   |
				; |-----|-----|------------|
				;
	CPUS	==	0x00	; CPU oscillator Source Select Bit.
				; "0" : run on Sub Oscillator
				; "1" : run on Main Oscillator
				;
				; bit 7 not use
	mCLK2	==	0x40	; Main Clock Select Bit[2] for PLL Mode
	mCLK1	==	0x20	; Main Clock Select Bit[1] for PLL Mode
	mCLK0	==	0x10	; Main Clock Select Bit[0] for PLL Mode
	mIDLE	==	0x08	; IDLE Mode Select Bit
	mBF1	==	0x04	; LCD Booster Frequency Select Bit[1]
	mBF0	==	0x02	; LCD Booster Frequency Select Bit[0]
	mCPUS	==	0x01	; CPU oscillator Source Select Bit.
     ;}	
;
; IR (Infrared) Control and PORT5 External Function Pins Set Register
;
 RE	==	0X0E
 IRCR	==	0X0E
;
     ;{
	IRE	==	0x07	; IR/PWM Enable Bit.
				; "0" : Disable
				; "1" : Enable
	HF	==	0x06	; IR/PWM Select Bit
				; "0" : for PWM
				; "1" : for IR
	LGP	==	0x05	; Long Pulse, Only Output Low Pulse.
				; "0" : Normal
				; "1" : Only Output LPWT (Include Carrier Freq.)
				; bit 4 not use
	IROUTE	==	0x03	; Control Bit is used to define the function of P5.7(IROUT) Pin
				; "0" : P5.7,bi-directional I/O Pin.
				; "1" : IROUT Pin. The bit7 of IOC50 must be set to "0"
	TCCE	==	0x02	; Control Bit is used to define the function of P5.6(TCC) Pin
				; "0" : P5.6,bi-directional I/O Pin.
				; "1" : External input pin of TCC. The bit6 of IOC50 must be set to "1"
	EINT1	==	0x01	; Control Bit is used to define the function of P5.5(INT1) Pin
				; "0" : P5.5,bi-directional I/O Pin.
				; "1" : INT1,External Interrupt Pin. The bit5 of IOC50 must be set to "1"
	EINT0	==	0x00	; Control Bit is used to define the function of P5.4(INT0) Pin
				; "0" : P5.4,bi-directional I/O Pin.
				; "1" : INTO,External Interrupt Pin. The bit4 of IOC50 must be set to "1"
				;
	mIRE	==	0x80	; IR/PWM Enable Bit.
	mHF	==	0x40	; IR/PWM Select Bit.
	mLGP	==	0x20	; Long Pulse, Only Output Low Pulse.
	mIROUTE	==	0x08	; Control Bit is used to define the function of P5.7(IROUT) Pin
	mTCCE	==	0x04	; Control Bit is used to define the function of P5.6(TCC) Pin
	mEINT1	==	0x02	; Control Bit is used to define the function of P5.5(INT1) Pin
	mEINT0	==	0x01	; Control Bit is used to define the function of P5.4(INT0) Pin
     ;}
;
; Interrupt Status Register
;
 RF	==	0X0F
 ISR	==	0X0F
;
     ;{
				; Totally "0" : Interrupt not Occur
				;	  "1" : Interrupt Occur
				;
	ICIF	==	0x07	; Pin Change Wake Up Interrupt Flag 
	LPWTF	==	0x06	; Low Pulse Width Timer Interrupt Flag
	HPWTF	==	0x05	; High Pulse Width Timer Interrupt Flag
	CNT2F	==	0x04	; Counter 2 Interrupt Flag
	CNT1F	==	0x03	; Counter 1 Interrupt Flag
	INT1F	==	0x02	; INT1 Interrupt Flag
	INT0F	==	0x01	; INT0 Interrupt Flag
	TCIF	==	0x00	; TCC Interrupt Flag
				;
	mICIF	==	0x80	; Pin Change Wake Up Interrupt Flag 
	mLPWTF	==	0x40	; Low Pulse Width Timer Interrupt Flag
	mHPWTF	==	0x20	; High Pulse Width Timer Interrupt Flag
	mCNT2F	==	0x10	; Counter 2 Interrupt Flag
	mCNT1F	==	0x08	; Counter 1 Interrupt Flag
	mINT1F	==	0x04	; INT1 Interrupt Flag
	mINT0F	==	0x02	; INT0 Interrupt Flag
	mTCIF	==	0x01	; TCC Interrupt Flag
     ;}
;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -