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

📄 01lcdclk.s

📁 用SAM72N9写的电子秤文档
💻 S
📖 第 1 页 / 共 4 页
字号:
;ToggleHalfSecFlag:
;	ld	x,AppFlags
;	xor	mx,HalfSecFlag
;	fan	mx,HalfSecFlag
;	jp	nz,xToggleHalfS
;	or	mx,SecClickFlag	; set flag if from 1->0
;xToggleHalfS:
;	ret

;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : check if up to 1 minute
; Desc   : IncSecond
; I/P    : --
; O/P    : --
; Destroy:
; Note   : c=0 if not up to 1 minute, c=1 if up to 1 minute
IncSecond:
	ld	x,RTCSec
	calz	IncByteD
	ld	x,RTCSec
	calz	IsEqu60
	ret
	
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : is che memory equ 60h
; Desc   : IsEqu60
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
IsEqu60:       
	cp	mx,00h
	jp	z,IsEqu0
;	rcf	
;	ret        
;	jp	IsEqu2      
	jp	IsRight8                              
IsEqu0:
	inc	x                                                      
	cp	mx,06h                                      
	jp	z,IsEqu1		; jmp if 1 minute time out  
IsRight8:
	rcf
	ret 
IsEqu1:                                                      
	ld	mx,0			; clr the memory 
IsEquE:  
	scf                                      
	ret              
                               
;
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : is che memory equ 24h
; Desc   : IsEqu24
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
IsEqu24:       
	cp	mx,04h
	jp	z,IsEqu240
	jp	IsRight8                     
IsEqu240:
	push	xl
	inc	x 
	cp	mx,02h            
	pop	xl                           
	jp	z,IsEqu241		; jmp if 1 minute time out  
	jp	IsRight8                                               
IsEqu241:    
        ldpx	mx,0
        ld	mx,0 
	jp	IsEquE

FlashTimeFormat:   
	ld	x,AppFlags
	FAN	mx,HalfSecFlag
	Jp	z,DspHourOff      
	
;-------------------------------------
; Cate   : display
; By     : Hcy
; Func   : display '24:H' or '12:H'
; Desc   : DspTimeFormat
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
DspTimeFormat:
	ld	x,RegKeyFlags
	fan	mx,TimeFormatFlag
	jp	nz,DspTime0		; jmp if 24 hour
	ld	a,1
	ld	x,090h
	calz	DspPattern
	ld	a,2
	calz	DspPattern
	jp	DspTime1
DspTime0:
	ld	a,2
	ld	x,090h
	calz	DspPattern
	ld	a,4
	calz	DspPattern
DspTime1:
	ld	a,0
	calz	DspPattern1		; display 'H'
	ld	a,7
	calz	DspPattern1		; display ' '
	jp	DspColonOn	
;-------------------------------------                        
; Cate   : Clock                                              
; By     : Hcy                                                
; Func   : check if up to 1 hour                            
; Desc   : IncMinute                                        
; I/P    : --                                                 
; O/P    : --                                                 
; Destroy:                                                    
; Note   : c=0 if not up to 1 minute, c=1 if up to 1 minute   
IncMinute:                                                   
	ld	x,RTCMin      
	calz	IncByteD    
	ld	x,RTCMin                    
	calz	IsEqu60                    
	ret                                
;
;-------------------------------------                        
; Cate   : Clock                                              
; By     : Hcy                                                
; Func   : check if up to 1 hour                            
; Desc   : IncHour                                        
; I/P    : --                                                 
; O/P    : --                                                 
; Destroy:                                                    
; Note   : c=0 if not up to 24 hour, c=1 if up to 24 hour   
IncHour:                                                   
	ld	x,RTCHour      
	calz	IncByteD    
	ld	x,RTCHour                    
	calz	IsEqu24                    
	ret                                
;
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : clear the byte
; Desc   : ClrByte
; I/P    : x(ram address)
; O/P    : --
; Destroy:
; Note   :
;ClrByte:
;	ld	a,0
;	ld	mx,a
;	inc	x
;	ld	mx,a
;	ret
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : inc setting HOUR
; Desc   : IncSetHour
; I/P    : --
; O/P    : --
; Destroy:
; Note   : 
;IncSetHour:
;	ld	x,TmpRTCHour
;	calz	IncByteD
;	ld	x,TmpRTCHour
;	calz	IsEqu24
;	jp	nc,IncSet0
;	ld	x,TmpRTCHour
;	calz	ClrByte
;IncSet0:
;	ld	y,TmpRTCHourL
;	calz	DspHour
;	ret
	
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : inc setting minute
; Desc   : IncSetMinute
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
;IncSetMinute:
;	ld	x,TmpRTCMinute
;	calz	IncByteD
;	ld	x,TmpRTCMinute
;	calz	IsEqu60
;	ld	y,TmpRTCMinuteL
;	calz	DspMinute
;	ret
;-------------------------------------
; Cate   : Common
; By     : Hcy
; Func   : copy 2-byte to other memory, (buffer1) --> (buffer2)
; Desc   : Copy2Byte
; I/P    : x(buffer 1 low address), y(buffer 2 low address)
; O/P    :
; Destroy:
; Note   :
;Copy2Byte:
;	ld	a,4
;Copy0:
;	ld	my,mx
;	inc	x
;	inc	y
;	add	a,0fh		; dec a
;	jp	nz,Copy0
;	ret	
;---------------------------------------
;---------------------------------------
;	Communication Routine
;---------------------------------------
;---------------------------------------
;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : reload the communication variable
; Desc   : ReloadCommVar
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
;ReloadCommVar:
;	ld	y,CommBufferL
;	ld	my,0		; clr the communication buffer
;	ld	y,CommCount
;	ld	my,04h		; reload the communication bit counter
;	ret

;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : store to the receive buffer
; Desc   : ToRecBuffer
; I/P    : --
; O/P    : --
; Destroy:
; Note   :	
;ToRecBuffer:
;	ld	y,RxStartBufL
;	ld	x,RxNibbleCnt
;	ld	a,mx
;Prog1:
;	ld	YL,a
;Prog2:
;	ld	x,CommBufferL
;	ld	my,mx		; store receive data to receive buffer
;	ret

;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : is che memory equ 1bh
; Desc   : IsEquStartCode
; I/P    : Y(start code address)
; O/P    : --
; Destroy:
; Note   : c=1 if not equal 1bh, c=0 if equal 1bh	
;IsEquStartCode:
;	ld	y,RxStartBufL
;	cp	my,0Bh
;	jp	z,IsEquEE
;IsEquE:
;	scf	
;	ret                                            
;IsEquEE:
;	rcf
;	ret   


                                           
;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : is receive command right ? 
; Desc   : IsRightCmd
; I/P    : --
; O/P    : --
; Destroy:
; Note   : c=1 if undefined command, c=0 if defined command
;IsRightCmd:
;	ld	x,RxCommand
;	cp	mx,SHOWLDIGITCMD
;	jp	nz,IsRight0
;	; show Ldigit command
;	ld	x,SumNumRxNibble
;	ld	mx,0ch
;	jp	IsRight8
;IsRight0:
;	cp	mx,SHOWSDIGITCMD
;	jp	nz,IsRight1
;	; show Sdigit command
;	ld	x,SumNumRxNibble
;	ld	mx,1
;IsRight8:
;	rcf
;	ret
;IsRight1:
;	cp	mx,SHOWICONCMD
;	jp	nz,IsRight2
;	; show icon command
;	ld	x,SumNumRxNibble
;	ld	mx,4
;	ld	x,RxNibbleCnt
;	ld	mx,0ch			; 
;	jp	IsRight8
;IsRight2:
;	cp	mx,SHOWMSGCMD
;	jp	nz,IsEquE
;	; show msg command
;	jp	IsRight8

;;-------------------------------------
; Cate   : Display
; By     : Kwan
; Func   : Clear the LCD ram including digits/icons
; Desc   :
; I/P    :
; O/P    :
; Destroy:
; Note   :
;LCDClr:
;	LD	x,90h
;LCDClr0:
;	ldpx	mx,0
;	cp	xh,0bh		; LCD ram from 90 to AFH
;	jp	nz, LCDClr0
;	ret
;
;;-------------------------------------
; Cate   : KeyBoard
; By     : Kwan
; Func   : Key board scan, set NewKey flag if new key found
;	   set  keyhold flag if the new key is still in-held
; Desc   :
; I/P    :
; O/P    : 
; Destroy:
; Note   : After calling subr, the newkey flag should be 
;	   checked.
;	   For MaB key, the Keyholdkey should be cleared before
;	   activating the corresponding function
;          For MbB key, no need to check the KeyHoldFlag before
;          activating the corr. function
;	   For MaH, the hold time must be checked to be 255 before
;	   activating the corr. function.
;
;KeyScan:	
;	ld	b,Key_On
;	ld	x,KPort
 ;       fan	mx,IO_Key_On
;	jp	z,KeyFound0		; br if Key_on is preseed (=1)
;	call	Dly17ms
;	fan	mx,IO_Key_On
;	jp	nz,KeyFound
;KeyFound0:
;	ld	b,Key_Off
;	fan	mx,IO_Key_Off
;	jp	z,KeyFound1		; br if Key_off is preseed
;	call	Dly17ms
;	fan	mx,IO_Key_Off
;	jp	nz,KeyFound
;;
;KeyFound1:	
;	ld	b,Key_Kg
;	ld	x,PPort
;	fan	mx,IO_Key_Kg
;	jp	nz,KeyFound2		; br if Key_Kg is preseed
;	call	Dly17ms
;	fan	mx,IO_Key_Kg
;	jp	nz,KeyFound
;;
;KeyFound2:
;	ld	b,Key_ml
;	fan	mx,IO_Key_ml
;	jp	nz,KeyFound3		; br if Key_ml is preseed
;	call	Dly17ms
;	fan	mx,IO_Key_ml
;	jp	nz,KeyFound
;;
;KeyFound3:
;	LD	X,RegKeyFlags
;	AND	MX, 0fh-KeyHoldFlag
;NotNewKey:
;	RZF				; return with Z=0 
;	RET
;KeyFound:
;	LD	X,RegKeyFlags
;	FAN	MX,KeyHoldFlag
;	JP	nz,NotNewKey		; br if not new Key
;	OR	MX,NewKeyFlag+KeyHoldFlag	; set key flag
;	LD	KeyCode,B
;	SZF				; return with Z-1 if new key MbB
;	RET

;===============================================	
; Reset vectors are located at page 1
	ORG	100H
	JP	Init		; reset vector
	JP	IntRTC		; clock interrupt -- may only be used to set flag
;
	ORG	104H
	JP	IntKPort	; Key port interrupt 
;	JP	IntRTC_KPort	; timer and key port interrupt both
;
; All reset, clock and Key port interrupt should be located in 100H page

	ORG 110h
;-------------------------------------
; Cate   : System
; By     : Hcy
; Func   : check the interrupt timer 1/8 sec and 1/2 sec
; Desc   : ChkTimer
; I/P    : --
; O/P    : --
; Destroy:
; Note   :	
ChkTimer:
	ld	x,TIntFactor
	ld	a,mx		; read and clear any interrupt request flags
	fan	a,0010b		; chk 1/8 sec
	jp	z,TimeSet00
	ld	b,KeyCode
	cp	b,Key_ml
	jp	nz,TimeN0
	inc	KeyHoldTm	; inc the keyhold time
TimeN0:
	call	KeyScan
TimeSet00:	
	fan 	a,0100b			; chk 1/2 sec
	jp	z,TimeSet01
	ld	a,Tmr1s
	fan	a,1111b
	jp	z,TimeR0
	dec	Tmr1s
	jp	TimeR1
	; add by hcy 03-11-29 11:35
TimeR0:
	ld	X,RegKeyFlags
	AND	MX,0fh-DisFlashFlag	; clr the key
TimeR1:	
	call	ToggleHalfSecFlag	
	ld	x,AppFlags
	fan	mx,SecClickFlag
TimeSet01:
	jp	z,TimeS0		; br if just 0.5 sec
;	
	and	mx,0fh-SecClickFlag	; clear the bit
; update the clock per 1 min
;	
;	 add it by hcy for return to the view clock within 30s without key
; remove it by hcy 03-12-15 16:12 for auto off timer -->2 minutes	
;	ld	a,Tmr15s
;	fan	a,1111b
;	jp	z,NewTime0
;	dec	Tmr15s			; dec timer 30s

	calz	IncSecond
	jp	nc,TimeS0		; No display update if change in second only
	; modify it by hcy
	ld	a,Tmr2Min
	fan	a,1111b
	jp	z,NewTime0
	dec	Tmr2Min	
NewTime0:
	calz	IncMinute
	jp	nc,TimeS0
	calz	IncHour
TimeS0:	
	ret

;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : toggle the half sec flag
; Desc   : ToggleHalfSecFlag
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
ToggleHalfSecFlag:
	ld	x,AppFlags
	xor	mx,HalfSecFlag
	fan	mx,HalfSecFlag
	jp	nz,xToggleHalfS
	or	mx,SecClickFlag	; set flag if from 1->0
xToggleHalfS:
	ret

;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : inc setting HOUR
; Desc   : IncSetHour
; I/P    : --
; O/P    : --
; Destroy:
; Note   : 
IncSetHour:
	ld	x,TmpRTCHour
	calz	IncByteD
	ld	x,TmpRTCHour
	calz	IsEqu24
	jp	nc,IncSet0
	ld	x,TmpRTCHour
	call	ClrByte
IncSet0:
	ld	y,TmpRTCHourL
	calz	DspHour
	ret
	
;-------------------------------------
; Cate   : Common
; By     : Hcy
; Func   : copy 2-byte to other memory, (buffer1) --> (buffer2)
; Desc   : Copy2Byte
; I/P    : x(buffer 1 low address), y(buffer 2 low address)
; O/P    :
; Destroy:
; Note   :
;Copy2Byte:
;	ld	a,4
;Copy0:
;	ld	my,mx
;	inc	x
;	inc	y
;	add	a,0fh		; dec a
;	jp	nz,Copy0
;	ret		

;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : reload the communication variable
; Desc   : ReloadCommVar
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
ReloadCommVar:
	ld	y,CommBufferL
	ld	my,0		; clr the communication buffer
	ld	y,CommCount
	ld	my,04h		; reload the communication bit counter
	ret
;-------------------------------------
; Cate   : communication
; By     : Hcy
; Func   : store to the receive buffer
; Desc   : ToRecBuffer
; I/P    : --
; O/P    : --
; Destroy:
; Note   :	
ToRecBuffer:
	ld	y,RxStartBufL
	ld	x,RxNibbleCnt
	ld	a,mx
Prog1:
	ld	YL,a
Prog2:
	ld	x,CommBufferL
	ld	my,mx		; store receive data to receive buffer
	ret
;;-------------------------------------
; Cate   : Display
; By     : Kwan
; Func   : Clear the LCD ram including digits/icons
; Desc   :
; I/P    :
; O/P    :
; Destroy:
; Note   :
LCDClr:
	LD	x,90h
LCDClr0:
	ldpx	mx,0
	cp	xh,0bh		; LCD ram from 90 to AFH
	jp	nz, LCDClr0
	ret
	
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : inc setting minute
; Desc   : IncSetMinute
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
IncSetMinute:
	ld	x,TmpRTCMinute
	calz	IncByteD
	ld	x,TmpRTCMinute
	calz	IsEqu60
	ld	y,TmpRTCMinuteL
	calz	DspMinute
	ret

;-------------------------------------
; Cate   : Application
; By     : Hcy
; Func   : 
; Desc   : CopyByte
; I/P    : y(ram address)
; O/P    :
; Destroy:
; Note   :
CopyByte:
	ld	x,DspHourBuf
	ld	mx,my
	inc	y
	inc	x
	ld	mx,my		; ram --> dsphourbuf
	ret
;-------------------------------------
; Cate   : Application
; By     : Hcy
; Func   : -0ch   by decimal
; Desc   : Sub12D
; I/P    : y(address of buffer)
; O/P    :  
; Destroy:
; Note   :
Sub12D:
	push	yl
	call	CopyByte
	pop	yl
	ld	x,DspHourBuf
;	SET	F,0100B     
	SDF
	RCF                 
	sbc     Mx,02h      
	inc	x           
	sbc     Mx,01h      
;	RST	F,1011B        
	RDF
	RET
	
;
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : is che memory equ 12h
; Desc   : IsEqu24
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
IsEqu12:    
	cp	my,02h
	jp	z,IsEqu120
	rcf	
	ret               
            
IsEqu120:
	push	yl
	inc	y                                                      
	cp	my,01h  
	pop	yl                                    
	jp	z,IsEqu121		; jmp if 1 minute time out  
	rcf
	ret  
IsEqu121:      
	call	CopyByte            
	scf                                      
	ret 	

;
;-------------------------------------
; Cate   : Clock
; By     : Hcy
; Func   : is che memory equ 0
; Desc   : IsEqu24
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
IsEquZero:    
	cp	my,0
	jp	z,IsEqu00
	rcf	

⌨️ 快捷键说明

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