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

📄 cnvlcdclk.ms

📁 用SAM72N9写的电子秤文档
💻 MS
📖 第 1 页 / 共 5 页
字号:
TurnOnPwr:
.stabn 1996, LineInfo
	ld	y,(0x0F3)		; set D_Out Hi after sending
.stabn 1997, LineInfo
	or	my,0b0011	; turn on power to samsung clk_in default high
.stabn 1998, LineInfo
	call	Dly125ms
.stabn 1999, LineInfo
	call	Dly125ms
.stabn 2000, LineInfo
	ret
;
;;======================================
; Key handling from here after
;
; Press and hold Kg > 2 seconds to enter the clock setting mode
; the Hour digits will be firstly flashed and use the ekys
; 1. Key_ml to toggle 12/24 mode
; 2. Key_kg to select  hour-adjusting
; 3. press the Key_ml to increment the hour
; 4. Press the Key_Kg to confirm the hour and select minute-adjusting
; 5. Press the Key_ml to increment the minute
; 6. Press the Key_Kg to complete the time setting.
; 
; Remark: turn off the ADC power in Clock/Clock setting  mode
; 	  no colon/second counting during clock setting mode
;         clear the second register after setting
;
Main_KeyHandle:
.stabn 2019, LineInfo
	LD	A,(M3)
.stabn 2020, LineInfo
	CP	A,(0b0111)
.stabn 2021, LineInfo
	JP	z,GetKey_On
.stabn 2022, LineInfo
	CP	A,(0b1101)
.stabn 2023, LineInfo
	JP	z,GetKey_Kg
.stabn 2024, LineInfo
	CP	A,(0b1011)
.stabn 2025, LineInfo
	JP	z,GetKey_ml
.stabn 2026, LineInfo
	CP	A,(0b1110)
.stabn 2027, LineInfo
	JP	z,GetKey_Off
.stabn 2028, LineInfo
	JP	ProgStartLp

;
GetKey_On:
; for testing
.stabn 2033, LineInfo
	LD	X,(1)
.stabn 2034, LineInfo
	FAN	MX,(1)
.stabn 2035, LineInfo
	JP	nz,ProgStartLp		; still key hold
.stabn 2036, LineInfo
	AND	MX,0x0f-(2)	; process the key & clr the flag

.stabn 2038, LineInfo
	ld	x,(0x31)
.stabn 2039, LineInfo
	fan	mx,0x0f
.stabn 2040, LineInfo
	jp	nz,GetK0		; jmp if not clock mode
	
;	ld	y,RPort		; set D_Out Hi after sending
;	or	my,0011b	; turn on power to samsung clk_in default high
.stabn 2044, LineInfo
	add	mx,1
.stabn 2045, LineInfo
	CALl	LCDClr
.stabn 2046, LineInfo
	LD	X,(0x16)
.stabn 2047, LineInfo
	AND	MX,0x0f-(4)	; clear the flag after sending
	; add 03-11-29 19:08
;	ld	y,RPort		; set D_Out Hi after sending
;	or	my,0011b	; turn on power to samsung clk_in default high
;	call	Dly125ms
;	call	Dly125ms

.stabn 2054, LineInfo
	call	TurnOnPwr
.stabn 2055, LineInfo
	call	ReloadCommVar
.stabn 2056, LineInfo
	ld	x,(0x30)
.stabn 2057, LineInfo
	ld	mx,0x0d
.stabn 2058, LineInfo
	ld	x,(0x1d)
.stabn 2059, LineInfo
	ld	mx,0
.stabn 2060, LineInfo
	jp	ProgStart		; to show Clock
	
GetK0:
.stabn 2063, LineInfo
	LD	(M4),B		;
.stabn 2064, LineInfo
	LD	X,(0x16)
.stabn 2065, LineInfo
	OR	MX,(4)
.stabn 2066, LineInfo
	jp	ProgStartLp
			


GetKey_ml:
.stabn 2071, LineInfo
	LD	X,(1)
.stabn 2072, LineInfo
	FAN	MX,(1)
.stabn 2073, LineInfo
	JP	nz,ProgStartLp		; still key hold
.stabn 2074, LineInfo
	AND	MX,0x0f-(2)	; process the key & clr the flag
;
; process the ml key here after

;	LD	SendData,B		;
;	LD	X,AppFlags
;	OR	MX,ReqToSendFlag
;	JP	ProgStartLp

.stabn 2083, LineInfo
	jp	GetK0

;
; process the Off key here after
GetKey_Off:
.stabn 2088, LineInfo
	ld	x,(0x31)
.stabn 2089, LineInfo
	cp	mx,(0)
.stabn 2090, LineInfo
	jp	z,ProgStartLp
TurnOffPwr:
.stabn 2092, LineInfo
	call	ClrKeyVar
.stabn 2093, LineInfo
	ld	x,(0x31)
.stabn 2094, LineInfo
	ld	mx,(0)		; Reset modeOpt if not valid
.stabn 2095, LineInfo
	CALl	LCDClr
.stabn 2096, LineInfo
	ld	y,(0x0F3)		; set D_Out Hi after sending
.stabn 2097, LineInfo
	and	my,0b0010	; turn off POWER_CONTROL
.stabn 2098, LineInfo
	jp	ProgStart
;

GetKey_Kg:
.stabn 2102, LineInfo
	LD	Y,(0x31)
.stabn 2103, LineInfo
	CP	MY,(0)
;	JP	nz,WeigthKey_Kg	; br if not clock mode	
.stabn 2105, LineInfo
	jp	nz,GetKey_ml	; br if not clock mode
	
.stabn 2107, LineInfo
	ld	X,(1)
.stabn 2108, LineInfo
	fan	MX,(1)
.stabn 2109, LineInfo
	jp	nz,GetKey_Kg0	; br to check the hold time
	
.stabn 2111, LineInfo
	AND	MX,0x0f-(2)	; ignor the key
.stabn 2112, LineInfo
	call	ClrKeyHoldTm
.stabn 2113, LineInfo
	jp	ProgStartLp
;
; starting from here if the key hold time > 2 seconds
;
GetKey_Kg0:
.stabn 2118, LineInfo
	ld	a,(M0)
.stabn 2119, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2120, LineInfo
	jp	nz,ProgStartLp	; br if Hold time < 2 seconds
.stabn 2121, LineInfo
	ld	x,(1)
.stabn 2122, LineInfo
	and	mx,0x0f-(2)	; clear the flag
;
; Time setting mode from here on

.stabn 2126, LineInfo
	call	ClrSetTimeVar
;	ld	a,Key_Nil
;	ld	KeyCode,a	; clr key code
;	ld	X,RegKeyFlags
;	AND	MX,0fh-DisFlashFlag	; clr the key
.stabn 2131, LineInfo
	ld	x,(0x12)
.stabn 2132, LineInfo
	ld	y,(0x18)
.stabn 2133, LineInfo
	call	Copy2Byte
.stabn 2134, LineInfo
	calz	DspColonOn
TimeSet:
.stabn 2136, LineInfo
	ld	X,(1)
.stabn 2137, LineInfo
	FAN	MX,(4)
.stabn 2138, LineInfo
	jp	nz,TimeSett0
.stabn 2139, LineInfo
	ld	y,(0x1a)
.stabn 2140, LineInfo
	calz	FlashHour
TimeSett0:
.stabn 2142, LineInfo
	call	ChkTimer

.stabn 2144, LineInfo
	LD	A,(M3)
.stabn 2145, LineInfo
	CP	A,(0b1101)
.stabn 2146, LineInfo
	JP	z,UTimeSet0	;; jmp to setting minute
.stabn 2147, LineInfo
	CP	A,(0b1011)
.stabn 2148, LineInfo
	jp	z,TimeSet1	; jmp to setting increase hour
.stabn 2149, LineInfo
	jp	TimeSet
	
TimeSet1:
.stabn 2152, LineInfo
	ld	X,(1)
;	OR	MX,DisFlashFlag
.stabn 2154, LineInfo
	fan	MX,(1)
.stabn 2155, LineInfo
	jp	nz,TimeSet2		; br to check the hold time
	
.stabn 2157, LineInfo
	AND	MX,0x0f-(2)	; clr the key
	; remark by hcy 03-11-29 11:44
;	AND	MX,0fh-DisFlashFlag	; clr the key
;	LD	a,0
;	ld	KeyHoldTm,a		; reset timer
;	ld	KeyCode,a		; clr the key code
.stabn 2163, LineInfo
	call	ClrKeyVar
HTimeSet:
.stabn 2165, LineInfo
	call	IncSetHour
	; add by hcy 03-11-29 11:33
.stabn 2167, LineInfo
	call	SetTmr1s
.stabn 2168, LineInfo
	jp	TimeSet
TimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
.stabn 2173, LineInfo
	OR	MX,(4)
.stabn 2174, LineInfo
	ld	a,(M0)
.stabn 2175, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2176, LineInfo
	jp	nz,TimeSet	; br if Hold time < 2 seconds
.stabn 2177, LineInfo
	ld	a,0x0d
.stabn 2178, LineInfo
	ld	(M0),a	; 
.stabn 2179, LineInfo
	jp	HTimeSet
;	call	IncSetHour	; 
;	jp	TimeSet
UTimeSet0:
.stabn 2183, LineInfo
	call	ClrSetTimeVar
;	ld	X,RegKeyFlags
;	AND	MX,0fh-DisFlashFlag	; clr the key
;	ld	a,Key_Nil
;	ld	KeyCode,a	; clr key code
.stabn 2188, LineInfo
	ld	y,(0x1a)
.stabn 2189, LineInfo
	calz	DspHour
.stabn 2190, LineInfo
	calz	DspColonOn
TimeSet0:
;	ld	y,TmpRTCHourL
;	calz	DspHour
;	calz	DspColonOn
.stabn 2195, LineInfo
	ld	X,(1)
.stabn 2196, LineInfo
	FAN	MX,(4)
.stabn 2197, LineInfo
	jp	nz,MTime0
	
.stabn 2199, LineInfo
	ld	y,(0x18)
.stabn 2200, LineInfo
	calz	FlashMinute
MTime0:
.stabn 2202, LineInfo
	call	ChkTimer

.stabn 2204, LineInfo
	LD	A,(M3)
.stabn 2205, LineInfo
	CP	A,(0b1101)
.stabn 2206, LineInfo
	JP	z,MTimeSet0	;; jmp to setting minute
.stabn 2207, LineInfo
	CP	A,(0b1011)
.stabn 2208, LineInfo
	jp	z,MTimeSet1	; jmp to setting increase hour
.stabn 2209, LineInfo
	jp	TimeSet0
	
MTimeSet1:
.stabn 2212, LineInfo
	ld	X,(1)
;	OR	MX,DisFlashFlag
.stabn 2214, LineInfo
	fan	MX,(1)
.stabn 2215, LineInfo
	jp	nz,MTimeSet2		; br to check the hold time
	
.stabn 2217, LineInfo
	AND	MX,0x0f-(2)	; clr the key
	; remark by hcy 03-11-29 11:44
;	AND	MX,0fh-DisFlashFlag	; clr the key
	
;	LD	a,0
;	ld	KeyHoldTm,a		; reset timer
;	ld	KeyCode,a		; clr the key code
.stabn 2224, LineInfo
	call	ClrKeyVar
HTimeSet0:
.stabn 2226, LineInfo
	call	IncSetMinute
	; add by hcy 03-11-29 11:40
.stabn 2228, LineInfo
	call	SetTmr1s
.stabn 2229, LineInfo
	jp	TimeSet0
MTimeSet2:
	
;
; starting from here if the key hold time > 2 seconds
;
.stabn 2235, LineInfo
	OR	MX,(4)
.stabn 2236, LineInfo
	ld	a,(M0)
.stabn 2237, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2238, LineInfo
	jp	nz,TimeSet0	; br if Hold time < 2 seconds
.stabn 2239, LineInfo
	ld	a,0x0d
.stabn 2240, LineInfo
	ld	(M0),a	; 
.stabn 2241, LineInfo
	jp	HTimeSet0

MTimeSet0:
.stabn 2244, LineInfo
	call	ClrKeyVar
.stabn 2245, LineInfo
	calz	ClrAmPm
	
	.org	0x300
	
TimeSet4:
.stabn 2250, LineInfo
	calz	FlashTimeFormat
.stabn 2251, LineInfo
	call	ChkTimer

.stabn 2253, LineInfo
	LD	A,(M3)
.stabn 2254, LineInfo
	CP	A,(0b1101)
.stabn 2255, LineInfo
	JP	z,TTimeSet0	;; jmp to exit setting
.stabn 2256, LineInfo
	CP	A,(0b1011)
.stabn 2257, LineInfo
	jp	z,TTimeSet1	; jmp to toggle time format
.stabn 2258, LineInfo
	jp	TimeSet4
	
TTimeSet1:
.stabn 2261, LineInfo
	ld	X,(1)
.stabn 2262, LineInfo
	fan	MX,(1)
.stabn 2263, LineInfo
	jp	nz,TimeSet4		; br to check the hold time
	
.stabn 2265, LineInfo
	AND	MX,0x0f-(2)	; clr the key
.stabn 2266, LineInfo
	call	ClrKeyVar
.stabn 2267, LineInfo
	ld	x,(1)
.stabn 2268, LineInfo
	xor	mx,(8)
.stabn 2269, LineInfo
	calz	DspTimeFormat
.stabn 2270, LineInfo
	jp	TimeSet4

TTimeSet0:
.stabn 2273, LineInfo
	ld	x,(0x18)
.stabn 2274, LineInfo
	ld	y,(0x12) 
.stabn 2275, LineInfo
	call	Copy2Byte	; 
.stabn 2276, LineInfo
	ld	x,(0x10)
.stabn 2277, LineInfo
	call	ClrByte
.stabn 2278, LineInfo
	ld	y,(0x14)
.stabn 2279, LineInfo
	calz	DspHour
.stabn 2280, LineInfo
	ld	y,(0x12)
.stabn 2281, LineInfo
	calz	DspMinute
.stabn 2282, LineInfo
	ld	X,(1)
.stabn 2283, LineInfo
	AND	MX,0x0f-(2)	; clr the key
.stabn 2284, LineInfo
	call	ClrKeyVar
.stabn 2285, LineInfo
	jp	ProgStartLp
;
;	ORG	300h
;WeigthKey_Kg:
;	LD	X,RegKeyFlags
;	FAN	MX,KeyHoldFlag
;	JP	nz,ProgStartLp		; still key hold
;	AND	MX,0fh-NewKeyFlag	; process the key & clr the flag
;;
;; process the Kg key here after
;	LD	SendData,B		;
;	LD	X,AppFlags
;	OR	MX,ReqToSendFlag
;	JP	ProgStartLp

;	org	340h
;
;-------------------------------------
; Cate   : Communication
; By     : Kwan
; Func   : SendKey
; Desc   : Send the key code to Samsung
; I/P    : 
; O/P    :
; Destroy:
; Note   : 1. Wait for the D_Clk=low to place the 
;             data bit to D_Out
;	   2. Wait for the D_Clk = hi again
;	   3. Wait the D_Clk=low to place the data
;		to D_Out until all 4 bit send
;	   4. the sync nibble (0AH) will be sent
;		first and followed by the keycode
;	   5. syn-nibble (=A) will be sent first and 
;		followed by a 4 bit data --> total 8 bits
;SendKey:
;;	call	SendSynBit
;	LD	A,0ah
;	CALL	Send4Bit
;; Check the time out if neccessary
;	LD	X,RegKeyCode
;	LD	A,MX
;	CALL	Send4Bit
;;
;	ld	y,RPort		; set D_Out Hi after sending
;	or	my,0011b
;; Check the time out if neccessary
;	RET
;
;-------------------------------------
; Cate   : communication                   
; By     : Hcy                             
; Func   : send 4 data bits (LSB first)
; Desc   : Send4Bit                      
; I/P    :                                 
; O/P    :
; Destroy:
; Note   :
Send4Bit:
.stabn 2343, LineInfo
	LD	X,(0x17)	
.stabn 2344, LineInfo
	LD	MX,4		; 4 bits
Send4BitLp1:
.stabn 2346, LineInfo
	LD	Y,(0x0E0)
Send4BitLp0:
.stabn 2348, LineInfo
	FAN	MY,0b0100	; wait for D_Clk Hi
.stabn 2349, LineInfo
	JP	z,Send4BitLp0
;
.stabn 2351, LineInfo
	ld	y,(0x0F3)
.stabn 2352, LineInfo
	RRC	A
.stabn 2353, LineInfo
	JP	C,Send4BitHi
.stabn 2354, LineInfo
	and	my,0b0001
.stabn 2355, LineInfo
	jp	Send4Bit0
Send4BitHi:
;	OR	my,0010b
.stabn 2358, LineInfo
	or	my,0b0011
Send4Bit0:
	
.stabn 2361, LineInfo
	LD	Y,(0x0E0)
Send4BitLp2:
.stabn 2363, LineInfo
	FAN	MY,0b0100	; wait for D_Clk Lo
.stabn 2364, LineInfo
	JP	nz,Send4BitLp2

.stabn 2366, LineInfo
	Add	mx,0x0f		; dec commcount		
.stabn 2367, LineInfo
	JP	nz,Send4BitLp1
;
xSend4Bit:	
.stabn 2370, LineInfo
	ret

;-------------------------------------
; Cate   : Delay
; By     : Hcy
; Func   : delay 20 ms
; Desc   : Dly20ms
; I/P    : 32*17*0.03125 = 17ms
; O/P    : --
; Destroy: y
; Note   :
;Dly17ms:
;	ld	y,0
;Dlym1:
;	inc	y
;	cp	yh,02h
;	jp	nz,Dlym1
;	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:	
.stabn 2408, LineInfo
	ld	b,(0b0111)
.stabn 2409, LineInfo
	ld	x,(0x0E0)
.stabn 2410, LineInfo
        fan	mx,(1)
.stabn 2411, LineInfo
	jp	z,KeyFound0		; br if Key_on is preseed (=1)
.stabn 2412, LineInfo
	call	Dly17ms
.stabn 2413, LineInfo
	fan	mx,(1)
.stabn 2414, LineInfo
	jp	nz,KeyFound
KeyFound0:
.stabn 2416, LineInfo
	ld	b,(0b1110)
.stabn 2417, LineInfo
	fan	mx,(2)
.stabn 2418, LineInfo
	jp	z,KeyFound1		; br if Key_off is preseed
.stabn 2419, LineInfo
	call	Dly17ms
.stabn 2420, LineInfo
	fan	mx,(2)
.stabn 2421, LineInfo
	jp	nz,KeyFound
;
KeyFound1:	
.stabn 2424, LineInfo
	ld	b,(0b1101)
.stabn 2425, LineInfo
	ld	x,(0x0F6)
.stabn 2426, LineInfo
	fan	mx,(1)
.stabn 2427, LineInfo
	jp	z,KeyFound2		; br if Key_Kg is preseed
.stabn 2428, LineInfo
	call	Dly17ms
.stabn 2429, LineInfo
	fan	mx,(1)
.stabn 2430, LineInfo
	jp	nz,KeyFound
;
KeyFound2:
.stabn 2433, LineInfo
	ld	b,(0b1011)
.stabn 2434, LineInfo
	fan	mx,(2)
.stabn 2435, LineInfo
	jp	z,KeyFound3		; br if 

⌨️ 快捷键说明

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