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

📄 01lcdclk.ms

📁 用SAM72N9写的电子秤文档
💻 MS
📖 第 1 页 / 共 5 页
字号:
.stabs "D:\Projects\Hcy_Projects\CLOCK_KITCHEN\SOURCE\01LCDDec22\01LCDClk.s", FileName
;
; Copy right Oriental Skill (Asia) Ltd 
; October 24, 2003
;
; Created by Kwan for Testing
;
;
; Scratch Pad memory from 0H ~ 0FH (M0~MF)
; User RAM from 10H ~ 2FH (32 nibbles)
; Stack from 30H~4FH
; LCD RAM from 90H ~ AFH -- However A4H~AFH may be used
; as user RAM because S13~S19 segment are not used
; in this application.
;
; v02 03-12-4 14:14 
;  1. after battery insert to the scale, the display time should be 12:00 a.m.
;  2. the scale can enter calibration moe at anytime during clock display
;  3. to avoid abnormal operarion, program EPSON IC so that it cann't turn on
;     within 2s after the scale turn off.
; v03 03-12-9 12:24
;  1. add the function that if no key input within 30s program return to 
;     the view clock mode
;  2. take away 'PermitSend' flag, when the under weight 'LDsp__' --> PrevWeightBCD

; v05 03-12-17 17:15
; 1, disable enter calibrate mode from the weighting mode
; 2. convert 'on'+'off' enter calibrate mode to 'on'+'ml/fl.oz' enter 
; 3. Key hold 2 sec to setting clock mode
;#define	SHOWLDIGITCMD	2
;#define	SHOWSDIGITCMD	3
;#define	SHOWICONCMD	4
;#define	SHOWMSGCMD	5

;#define	CLOCKMODE	0
;#define	WEIGHTMODE	1
;#define	CALIBRATEMODE	2

;#define	KeyHoldTm	M0
;#define	KeyFlags	M1
;#define	RegKeyFlags	1	; same as KeyFlags
;CommCount	EQU	M2	; bit count for comm
;#define	KeyHoldFlag	1
;#define	NewKeyFlag	2
;#define	DisFlashFlag	4
;#define	TimeFormatFlag	8	; 0: 12 hour, 1: 24 hour
;#define		KeyCode	M3
;#define	RegKeyCode	3
;#define	SendData	M4
;#define	RegSendData	4

;#define		Tmr2Min	M5
;CommFlag	EQU	M6
;#define	KeyHold2Sec	M2

;#define	ComDigHBuf	M6
;#define	DigitHBuf	M7

;#define		Tmr1s	M8
;#define		Tmr2s	M9


;
;#define		RTCSec	10H
;#define		RTCSecL	10H
;#define		RTCSecH	11H
;#define		RTCMin	12H
;#define		RTCMinL	12H
;#define		RTCMinH	13H
;#define		RTCHour	14H
;#define	RTCHourL	14H
;#define	RTCHourH	15H
;


;#define	RxStartBufL	20h	; start code 
;RxCommand	equ	21h
;#define	RxBuffer0	21H	; LSBL, ___1, decimal place
;#define	RxBuffer1	22H	; LSBH
;#define	RxBuffer2	23H	; xxx1
;#define	RxBuffer3	24H
;#define	RxBuffer4	25H	; xx1x
;#define	RxBuffer5	26H
;#define	RxBuffer6	27H	; x1xx
;#define	RxBuffer7	28H

;#define		RxIcon0	29h
;#define		RxIcon1	2ah
;#define		RxIcon2	2bH
;#define		RxIcon3	2cH
;#define	RxSBuffer	2dH	; SDIGIT

;#define	RxBuffer8	2eh
;#define	RxBuffer9	2fh

;#define	SumNumRxNibble	30h	; 
;

;#define		ModeOpt	31h	; 0: Clock Mode, 1: weighting Mode, 2: Calibration Mode

;#define	DspHourBuf	32H
;#define	DspHourLBuf	32H
;#define	DspHourHBuf	33H	

;#define	LCDMapMem0	34H	; 1ST DIGIT
;#define	LCDMapMem0H	35H
;#define	LCDMapMem1	36H	; 2ND DIGIT
;#define	LCDMapMem1H	37H
;#define	LCDMapMem2	38H	; 3RD DIGIT
;#define	LCDMapMem2H	39H
;#define	LCDMapMem3	3AH	; 4TH DIGIT
;#define	LCDMapMem3H	3BH
;#define	LCDMapMem4	3CH	; 5,6th digit
;#define	LCDMapMem4H	3DH
;#define	LCDMapMem5	3EH
;#define	LCDMapMem5H	3FH


;#define		AppFlags	16H	
;#define	HalfSecFlag	1
;#define	SecClickFlag	2
;#define	ReqToSendFlag	4	; set when 4 bits has been sent in background
;#define	Rx4BitFlag	8	; set when 4 bits has been received in background

;b0 -- Half second (0->1 0.5 sec, 1->0 1 sec)
;b1 -- second click
;b2 -- RxReady

;#define	CommCount	17H	; bit count for comm
;#define	TmpRTCMinute	18H
;#define	TmpRTCMinuteL	18H	; for the use of time adjustment
;#define	TmpRTCMinuteH	19H
;#define	TmpRTCHour	1AH
;#define	TmpRTCHourL	1aH
;#define	TmpRTCHourH	1bH
;
;#define	CommBufferL	1cH	; Tx/Rx Buffer

;RxNibbleCnt	equ	00h	; 

;#define	RxNibbleCnt	1dh
;#define		KeyFlag	1eH
;NewKey		bit	1eh.0
;KeyHold		bit	1eh.1

;#define	RTC1SecCnt	1fh

;
;
;===========================================================
; Registers
; IC: 6001
;#define		KPort	0E0H
;IO_Key_On	EQU	1
;IO_Key_Off	EQU	2
;IO_DClk		EQU	4
;;
;#define	IO_Key_On	1
;#define	IO_Key_Kg	2
;#define	IO_Key_ml	4  
;#define	IO_Key_Off	8


;#define		Timer	0E4H	; timer data register
;#define	KPortMask	0E8H	; interrupt mask for K-port
;#define	TimerMask	0EBH	
;#define	KIntFactor	0EDH	; interrupt request flags for Kport
;#define	TIntFactor	0EFH	; interrupt request flags for Timer
;
;#define		RPort	0F3H	; R0 data port
;#define	IO_PowerCtl	1
;#define	IO_DataOut	2
;
;#define		PPort	0F6H	; P0 data port
;IO_Key_Kg	EQU	1
;IO_Key_ml	EQU	2
;IO_DataIn	EQU	8
;;
;#define		TimerCR	0F9H
;b2=1 to reset clock timer
;
;#define	HeavyLoad	0FAH	; heavy load protection register
;b3=1 if heavy load, b3=0 if normal load
;
;#define	LCDSwitch	0FBH	;
;b3=1 if static, b3=0 if dynamic
;
;#define	PPortDir	0FCH	; P-port direction register
;b0=1 if whole P-port as output, b0=0 if as inout 
;
;#define	BuzzerFreq	0FDH	; Buzzer freq


;===========================================================
; Registers
; IC: 60R08
;KPort		EQU	0E3H
;;IO_Key_On	EQU	1
;;IO_Key_Off	EQU	2
;;IO_DClk		EQU	4
;IO_Key_On	EQU	1
;IO_Key_Kg	EQU	2
;IO_Key_ml	EQU	4  
;IO_Key_Off	EQU	8
;
;Timer		EQU	0E0H	; timer data register
;KPortMask	EQU	0E5H	; interrupt mask for K-port
;TimerMask	EQU	0E8H	
;KIntFactor	EQU	0EAH	; interrupt request flags for Kport
;TIntFactor	EQU	0E9H	; interrupt request flags for Timer
;
;RPort		EQU	0EBH	; R0 data port
;IO_PowerCtl	EQU	1
;IO_DataOut	EQU	2
;
;PPort		EQU	0EDH	; P0 data port
;;IO_Key_Kg	EQU	1
;;IO_Key_ml	EQU	2
;;IO_DataIn	EQU	8
;
;TimerCR		EQU	0EEH
;;b2=1 to reset clock timer
;;
;HeavyLoad	EQU	0E6H	; heavy load protection register
;;b3=1 if heavy load, b3=0 if normal load
;;
;LCDSwitch	EQU	0E8H	;
;;b3=1 if static, b3=0 if dynamic
;;
;PPortDir	EQU	0EEH	; P-port direction register
;;b0=1 if whole P-port as output, b0=0 if as inout 



;
; constants defintion
;
;#define		Key_On	0111b	; key code corr. to Samsung's code
;#define		Key_Off	1110b
;#define		Key_Kg	1101b
;#define		Key_ml	1011b
;#define		Key_Nil	0

; key code by hcy 
;Key_On		EQU	1110b	; key code corr. to Samsung's code
;Key_Off		EQU	0111b
;Key_Kg		EQU	1101b
;Key_ml		EQU	1011b
;Key_Nil		EQU	0


; define by hcy
;#define	Key_OnOff	0110b
;#define	Key_OnKg	0101b

;===========================================================
	.org	0
	
;-----------------------------------------------------------
;-----------------------------------------------------------
;	Display routine
;-----------------------------------------------------------
;-----------------------------------------------------------
;	hgfe dcba
.stabn 264, LineInfo
	retd	0x3f		; 0
.stabn 265, LineInfo
	retd	0x06		; 1
.stabn 266, LineInfo
	retd	0x5b		; 2
.stabn 267, LineInfo
	retd	0x4f		; 3
.stabn 268, LineInfo
	retd	0x66		; 4
.stabn 269, LineInfo
	retd	0x6d		; 5
.stabn 270, LineInfo
	retd	0x7d		; 6
.stabn 271, LineInfo
	retd	0x27		; 7
.stabn 272, LineInfo
	retd	0x7f		; 8
.stabn 273, LineInfo
	retd	0x6f		; 9
.stabn 274, LineInfo
	retd	0x77		; A
.stabn 275, LineInfo
	retd	0x7c		; b
.stabn 276, LineInfo
	retd	0x39		; C
.stabn 277, LineInfo
	retd	0x5e		; d
.stabn 278, LineInfo
	retd	0x79		; E
.stabn 279, LineInfo
	retd	0x71		; F
.stabn 280, LineInfo
	retd	0x76		; H
.stabn 281, LineInfo
	retd	0x38		; L
.stabn 282, LineInfo
	retd	0x50		; r
.stabn 283, LineInfo
	retd	0x73		; P
.stabn 284, LineInfo
	retd	0x78		; t
.stabn 285, LineInfo
	retd	0x3e		; U
.stabn 286, LineInfo
	retd	0x40		; -
.stabn 287, LineInfo
	retd	0x00		; ' '
	
	
	; fraction table
.stabn 291, LineInfo
	retd	0x18		; 
.stabn 292, LineInfo
	retd	0x14
.stabn 293, LineInfo
	retd	0x38
.stabn 294, LineInfo
	retd	0x12
.stabn 295, LineInfo
	retd	0x58
.stabn 296, LineInfo
	retd	0x34
.stabn 297, LineInfo
	retd	0x78
.stabn 298, LineInfo
	retd	0x98
	; denominator(2,4,8) and numerator(1,3,5,7,9) pattern
;	retd	00h		; dummy
;	retd	00h		; 1(numerator)
;	retd	4Ah		; 2(denominator)
;	retd	30h		; 3(numerator)
;	retd	0C4h		; 4(denominator)
;	retd	31h		; 5(numerator)
;	retd	00h		; dummy
;	retd	11h		; 7(numerator)
;	retd	0CEh		; 8(denominator)
;	retd	31h		; 9(numerator)

	
DspPattern:
.stabn 313, LineInfo
	ld	b,0
.stabn 314, LineInfo
	jpba

DspPattern1:
.stabn 317, LineInfo
	ld	b,1
.stabn 318, LineInfo
	jpba	
	
;DspDenoNume:
;	ld	b,2
;	jpba

;-------------------------------------
; Cate   : Display
; By     : Hcy
; Func   : display the digit(0--9)
; Desc   : DspDigit
; I/P    : A(0--9),X(address of digit address)
; O/P    : --
; Destroy: A,
; Note   :
DspDigit:
.stabn 334, LineInfo
	calz	DspPattern
.stabn 335, LineInfo
	ret
DspDigit1:
.stabn 337, LineInfo
	calz	DspPattern1
.stabn 338, LineInfo
	ret	
;-------------------------------------
; Cate   : Display
; By     : loren
; Func   : display the icon 
; Desc   : DspColonOn
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
DspColonOn:
.stabn 349, LineInfo
	ld	y,0x0a0
.stabn 350, LineInfo
	or	my,0x01			; display ':'
.stabn 351, LineInfo
	ret
	
;-------------------------------------
; Cate   : Display
; By     : loren
; Func   : display off the icon 
; Desc   : DspColonOff
; I/P    : --
; O/P    : --
; Destroy:
; Note   : 
DspColonOff:
.stabn 363, LineInfo
	ld	y,0x0a0
.stabn 364, LineInfo
	and	my,0b1110
DspCO:
.stabn 366, LineInfo
	ret

;-------------------------------------
;-------------------------------------
; Cate   :Dosplay
; By     :Kwan
; Func   :Flash the colon
; Desc   :
; I/P    :---
; O/P    :
; Destroy:
; Note   : turn on/off the colon according to 
; 	   HalfSecFlag
;
FlashColon:
.stabn 381, LineInfo
	ld	y,(0x31)
.stabn 382, LineInfo
	fan	my,0b1111
.stabn 383, LineInfo
	jp	nz,DspCO		; jmp if not clock mode
	
.stabn 385, LineInfo
	ld	y,(0x16)
.stabn 386, LineInfo
	FAN	my,(1)
.stabn 387, LineInfo
	Jp	z,DspColonOff
.stabn 388, LineInfo
	jp	DspColonOn

FlashHour:
.stabn 391, LineInfo
	ld	x,(0x16)
.stabn 392, LineInfo
	FAN	mx,(1)
.stabn 393, LineInfo
	Jp	z,DspHourOff
;-------------------------------------
; Cate   : Display
; By     : Hcy
; Func   : Display the time
; Desc   : DspTime
; I/P    : y(ram address)
; O/P    : --
; Destroy:
; Note   :
DspTime:
DspHour:
	; display hour xx
;	ld	x,RTCHourH
.stabn 407, LineInfo
	ld	x,(1)
.stabn 408, LineInfo
	fan	mx,(8)
.stabn 409, LineInfo
	jp	nz,DspH0			; jmp if 24 hour format
.stabn 410, LineInfo
	call	IsEquZero
.stabn 411, LineInfo
	jp	c,NDspH00
.stabn 412, LineInfo
	call	IsEqu12
.stabn 413, LineInfo
	jp	c,DspH00		; jmp if hour =12
.stabn 414, LineInfo
	call	Sub12D
.stabn 415, LineInfo
	jp	nc,DspH00		; current time > 12
.stabn 416, LineInfo
	call	CopyByte
;	ld	a,0ah
;	ld	x,098h
;	calz	DspPattern		; 'A'
NDspH00:
.stabn 421, LineInfo
	ld	a,0x01
.stabn 422, LineInfo
	ld	x,0x0a1
.stabn 423, LineInfo
	ld	mx,a			; 'AM'
.stabn 424, LineInfo
	jp	DspH1
DspH00:
;	ld	a,03h
;	ld	x,098h
;	calz	DspPattern1		; 'P'
.stabn 429, LineInfo
	ld	a,0x02
.stabn 430, LineInfo
	ld	x,0x0a1
.stabn 431, LineInfo
	ld	mx,a			; 'PM'
.stabn 432, LineInfo
	jp	DspH1
DspH0:
.stabn 434, LineInfo
	ld	a,7
.stabn 435, LineInfo
	ld	x,0x0a1
.stabn 436, LineInfo
	calz	DspPattern1		; ' ' 	
.stabn 437, LineInfo
	call	CopyByte
.stabn 438, LineInfo
	jp	NDspH0
DspH1:
;	ld	x,DspHourBuf
;	calz	IncByteD
NDspH0:
.stabn 443, LineInfo
	ld	y,(0x32)
.stabn 444, LineInfo
	ld	a,my
DspH2:
.stabn 446, LineInfo
	ld	x,0x092
.stabn 447, LineInfo
	calz	DspDigit              
.stabn 448, LineInfo
	ld	y,(0x33)
.stabn 449, LineInfo
	ld	a,my
.stabn 450, LineInfo
	fan	a,0b1111
.stabn 451, LineInfo
	jp	nz,NewDspH2
.stabn 452, LineInfo
	jp	NewDspH22
NewDspH2:
.stabn 454, LineInfo
	ld	x,0x090
.stabn 455, LineInfo
	calz	DspDigit
.stabn 456, LineInfo
	ret
DspHourOff:
	; off minute xx
.stabn 459, LineInfo
	ld	a,0x07	
.stabn 460, LineInfo
	ld	x,0x092
.stabn 461, LineInfo
	calz	DspDigit1
NewDspH22:
.stabn 463, LineInfo
	ld	a,0x07
.stabn 464, LineInfo
	ld	x,0x090
.stabn 465, LineInfo
	calz	DspDigit1
.stabn 466, LineInfo
	ret
	
FlashMinute:
.stabn 469, LineInfo
	ld	x,(0x16)
.stabn 470, LineInfo
	FAN	mx,(1)
.stabn 471, LineInfo
	Jp	z,DspMinuteOff	

DspMinute:
	; display min xx
;	ld	x,RTCMinH
.stabn 476, LineInfo
	ld	a,my
.stabn 477, LineInfo
	ld	x,0x096
.stabn 478, LineInfo
	calz	DspDigit
;	ld	x,RTCMinL
.stabn 480, LineInfo
	inc	y
.stabn 481, LineInfo
	ld	a,my
.stabn 482, LineInfo
	ld	x,0x094
.stabn 483, LineInfo
	calz	DspDigit
.stabn 484, LineInfo
	ret
DspMinuteOff:
	; off minute xx
.stabn 487, LineInfo
	ld	a,0x07
.stabn 488, LineInfo
	ld	x,0x094
.stabn 489, LineInfo
	calz	DspDigit1	
.stabn 490, LineInfo
	ld	x,0x096
.stabn 491, LineInfo
	calz	DspDigit1
.stabn 492, LineInfo
	ret


;-------------------------------------
; Cate   : Display
; By     : Hcy
; Func   : dislay the fraction
; Desc   : DspFraction
; I/P    : RxSBuffer(0--9) --> nul,1/8,1/4,3/8,1/2,5/8,3/4,7/8,9/8,nul
; O/P    : --
; Destroy:
; Note   :
DspFraction:
.stabn 505, LineInfo
	ld	y,(0x2d)
.stabn 506, LineInfo
	cp	my,0
.stabn 507, LineInfo
	jp	z,DspF0
.stabn 508, LineInfo
	cp	my,9
.stabn 509, LineInfo
	jp	z,DspF0
.stabn 510, LineInfo
	ld	a,my
.stabn 511, LineInfo
	add	a,0x07		; a+7
.stabn 512, LineInfo
	ld	x,(0x2e)
.stabn 513, LineInfo
	calz	DspPattern1
.stabn 514, LineInfo
	ld	y,(0x2e)
.stabn 515, LineInfo
	ld	a,my
.stabn 516, LineInfo
	ld	x,0x098
.stabn 517, LineInfo

⌨️ 快捷键说明

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