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

📄 01lcdclk.ms

📁 用SAM72N9写的电子秤文档
💻 MS
📖 第 1 页 / 共 5 页
字号:
.stabn 2037, LineInfo
	ld	a,0
.stabn 2038, LineInfo
	ld	(M0),a		; reset timer
.stabn 2039, LineInfo
	ret
;-------------------------------------
; Cate   : Delay
; By     : Hcy
; Func   : delay 125ms
; Desc   : Dly125ms
; I/P    : --
; O/P    : --
; Destroy:
; Note   :
;
Dly125ms:
.stabn 2051, LineInfo
	ld	x,0
Dlym0:
.stabn 2053, LineInfo
	inc	x
.stabn 2054, LineInfo
	cp	xh,0x0f
.stabn 2055, LineInfo
	jp	nz,Dlym0
.stabn 2056, 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 2077, LineInfo
	LD	A,(M3)
.stabn 2078, LineInfo
	CP	A,(0b0111)
.stabn 2079, LineInfo
	JP	z,GetKey_On
.stabn 2080, LineInfo
	CP	A,(0b1101)
.stabn 2081, LineInfo
	JP	z,GetKey_Kg
.stabn 2082, LineInfo
	CP	A,(0b1011)
.stabn 2083, LineInfo
	JP	z,GetKey_ml
.stabn 2084, LineInfo
	CP	A,(0b1110)
.stabn 2085, LineInfo
	JP	z,GetKey_Off
.stabn 2086, LineInfo
	JP	ProgStartLp

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

.stabn 2096, LineInfo
	ld	x,(0x31)
.stabn 2097, LineInfo
	fan	mx,0x0f
.stabn 2098, LineInfo
	jp	nz,GetK0		; jmp if not clock mode
	
.stabn 2100, LineInfo
	ld	a,(M9)
.stabn 2101, LineInfo
	fan	a,0b1111
.stabn 2102, LineInfo
	jp	nz,ProgStartLp
	
.stabn 2104, LineInfo
	LD	Y,(0x0F3)
	; 03-11-22 14:04 HCY
.stabn 2106, LineInfo
	LD	MY,0b0011	; Power on, CLK_IN default high
	
;	ld	y,RPort		; set D_Out Hi after sending
;	or	my,0011b	; turn on power to samsung clk_in default high
.stabn 2110, LineInfo
	add	mx,1
.stabn 2111, LineInfo
	CALl	LCDClr
.stabn 2112, LineInfo
	LD	X,(0x16)
.stabn 2113, LineInfo
	AND	MX,0x0f-(4)	; clear the flag after sending
.stabn 2114, LineInfo
	call	Dly125ms
.stabn 2115, LineInfo
	call	Dly125ms
.stabn 2116, LineInfo
	call	ReloadCommVar
.stabn 2117, LineInfo
	ld	x,(0x30)
.stabn 2118, LineInfo
	ld	mx,0x0d
.stabn 2119, LineInfo
	ld	x,(0x1d)
.stabn 2120, LineInfo
	ld	mx,0
.stabn 2121, LineInfo
	jp	ProgStart		; to show Clock
	
GetK0:
.stabn 2124, LineInfo
	ld	b,(M3)
.stabn 2125, LineInfo
	LD	(M4),B		;
.stabn 2126, LineInfo
	LD	X,(0x16)
.stabn 2127, LineInfo
	OR	MX,(4)
.stabn 2128, LineInfo
	jp	ProgStartLp
			


GetKey_ml:
.stabn 2133, LineInfo
	LD	X,(1)
.stabn 2134, LineInfo
	FAN	MX,(1)
.stabn 2135, LineInfo
	JP	nz,ProgStartLp		; still key hold
.stabn 2136, 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 2145, LineInfo
	jp	GetK0

;
; process the Off key here after
GetKey_Off:
;	LD	SendData,B		;
;	LD	X,AppFlags
;	OR	MX,ReqToSendFlag
.stabn 2153, LineInfo
	ld	x,(0x31)
.stabn 2154, LineInfo
	cp	mx,(0)
.stabn 2155, LineInfo
	jp	z,ProgStartLp
TurnOffPwr:
.stabn 2157, LineInfo
	ld	a,0
.stabn 2158, LineInfo
	ld	(M3),a
.stabn 2159, LineInfo
	ld	x,(0x31)
.stabn 2160, LineInfo
	ld	mx,(0)		; Reset modeOpt if not valid
.stabn 2161, LineInfo
	CALl	LCDClr
.stabn 2162, LineInfo
	ld	y,(0x0F3)		; set D_Out Hi after sending
;	and	my,0010b	; turn off POWER_CONTROL
.stabn 2164, LineInfo
	ld	my,0b0000	; turn off power_control ,clk_in is low
	
	; add it by hcy 03-12-4 14:13 
.stabn 2167, LineInfo
	ld	a,4
.stabn 2168, LineInfo
	ld	(M9),a		; 
.stabn 2169, LineInfo
	jp	ProgStart
;

GetKey_Kg:
.stabn 2173, LineInfo
	LD	Y,(0x31)
.stabn 2174, LineInfo
	CP	MY,(0)
;	JP	nz,WeigthKey_Kg	; br if not clock mode	
.stabn 2176, LineInfo
	jp	nz,GetKey_ml	; br if not clock mode
	
.stabn 2178, LineInfo
	ld	X,(1)
.stabn 2179, LineInfo
	fan	MX,(1)
.stabn 2180, LineInfo
	jp	nz,GetKey_Kg0	; br to check the hold time
	
.stabn 2182, LineInfo
	AND	MX,0x0f-(2)	; ignor the key
.stabn 2183, LineInfo
	call	ClrKeyHoldTm
.stabn 2184, LineInfo
	jp	ProgStartLp
;
; starting from here if the key hold time > 2 seconds
;
GetKey_Kg0:
.stabn 2189, LineInfo
	ld	a,(M0)
.stabn 2190, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2191, LineInfo
	jp	nz,ProgStartLp	; br if Hold time < 2 seconds
.stabn 2192, LineInfo
	ld	x,(1)
.stabn 2193, LineInfo
	and	mx,0x0f-(2)	; clear the flag
	
; Time setting mode from here on
;	ld	a,Key_Nil
;	ld	KeyCode,a	; clr key code
;	ld	KeyHoldTm,a
.stabn 2199, LineInfo
	ld	X,(1)
.stabn 2200, LineInfo
	AND	MX,0x0f-(4)	; clr the key
.stabn 2201, LineInfo
	ld	x,(0x12)
.stabn 2202, LineInfo
	ld	y,(0x18)
.stabn 2203, LineInfo
	call	Copy2Byte
.stabn 2204, LineInfo
	calz	DspColonOn
	
.stabn 2206, LineInfo
	ld	a,(0)
.stabn 2207, LineInfo
	ld	(M3),a	; clr key code
.stabn 2208, LineInfo
	ld	(M0),a
;	ld	a,0fh
;	ld	Tmr15s,a
.stabn 2211, LineInfo
	call	ReloadTmr2Min
TimeSet:
.stabn 2213, LineInfo
	ld	X,(1)
.stabn 2214, LineInfo
	FAN	MX,(4)
.stabn 2215, LineInfo
	jp	nz,TimeSett0
.stabn 2216, LineInfo
	ld	y,(0x1a)
.stabn 2217, LineInfo
	calz	FlashHour
TimeSett0:
.stabn 2219, LineInfo
	call	ChkTimer
.stabn 2220, LineInfo
	ld	a,(M5)
.stabn 2221, LineInfo
	fan	a,0b1111
.stabn 2222, LineInfo
	jp	z,NewE

.stabn 2224, LineInfo
	LD	A,(M3)
.stabn 2225, LineInfo
	CP	A,(0b1101)
.stabn 2226, LineInfo
	JP	z,UTimeSet0	;; jmp to setting minute
.stabn 2227, LineInfo
	CP	A,(0b1011)
.stabn 2228, LineInfo
	jp	z,TimeSet1	; jmp to setting increase hour
.stabn 2229, LineInfo
	jp	TimeSet
	
TimeSet1:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2234, LineInfo
	call	ReloadTmr2Min
.stabn 2235, LineInfo
	ld	X,(1)
.stabn 2236, LineInfo
	fan	MX,(1)
.stabn 2237, LineInfo
	jp	nz,TimeSet2		; br to check the hold time
	
.stabn 2239, 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 2245, LineInfo
	call	ClrKeyVar
.stabn 2246, LineInfo
	ld	a,(M2)
.stabn 2247, LineInfo
	cp	a,0x01
.stabn 2248, LineInfo
	jp	nz,HTimeSet
.stabn 2249, LineInfo
	ld	a,0
.stabn 2250, LineInfo
	ld	(M2),a
.stabn 2251, LineInfo
	jp	TimeSet
HTimeSet:
.stabn 2253, LineInfo
	call	IncSetHour
	; add by hcy 03-11-29 11:33
.stabn 2255, LineInfo
	call	SetTmr1s
.stabn 2256, LineInfo
	jp	TimeSet
TimeSet2:
;
; starting from here if the key hold time > 2 seconds
;
.stabn 2261, LineInfo
	OR	MX,(4)
.stabn 2262, LineInfo
	ld	a,(M0)
.stabn 2263, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2264, LineInfo
	jp	nz,TimeSet	; br if Hold time < 2 seconds
.stabn 2265, LineInfo
	ld	a,0x01
.stabn 2266, LineInfo
	ld	(M2),a
.stabn 2267, LineInfo
	ld	a,0x0d
.stabn 2268, LineInfo
	ld	(M0),a	; 
.stabn 2269, LineInfo
	jp	HTimeSet
;	call	IncSetHour	; 
;	jp	TimeSet


	.org	0x300

UTimeSet0:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2279, LineInfo
	call	ReloadTmr2Min
.stabn 2280, LineInfo
	ld	X,(1)
.stabn 2281, LineInfo
	AND	MX,0x0f-(4)	; clr the key
;	ld	a,Key_Nil
;	ld	KeyCode,a	; clr key code
;	ld	KeyHoldTm,a
.stabn 2285, LineInfo
	ld	y,(0x1a)
.stabn 2286, LineInfo
	calz	DspHour
.stabn 2287, LineInfo
	calz	DspColonOn
	
;	ld	a,Key_Nil
;	ld	KeyCode,a	; clr key code
;	ld	KeyHoldTm,a
.stabn 2292, LineInfo
	call	ClrKeyVar
TimeSet0:
;	ld	y,TmpRTCHourL
;	calz	DspHour
;	calz	DspColonOn
.stabn 2297, LineInfo
	ld	X,(1)
.stabn 2298, LineInfo
	FAN	MX,(4)
.stabn 2299, LineInfo
	jp	nz,MTime0
	
.stabn 2301, LineInfo
	ld	y,(0x18)
.stabn 2302, LineInfo
	calz	FlashMinute
MTime0:
.stabn 2304, LineInfo
	call	ChkTimer
.stabn 2305, LineInfo
	ld	a,(M5)
.stabn 2306, LineInfo
	fan	a,0b1111
.stabn 2307, LineInfo
	jp	z,NewE
	
.stabn 2309, LineInfo
	LD	A,(M3)
.stabn 2310, LineInfo
	CP	A,(0b1101)
.stabn 2311, LineInfo
	JP	z,MTimeSet0	;; jmp to setting minute
.stabn 2312, LineInfo
	CP	A,(0b1011)
.stabn 2313, LineInfo
	jp	z,MTimeSet1	; jmp to setting increase hour
.stabn 2314, LineInfo
	jp	TimeSet0
	
MTimeSet1:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2319, LineInfo
	call	ReloadTmr2Min
.stabn 2320, LineInfo
	ld	X,(1)
;	OR	MX,DisFlashFlag
.stabn 2322, LineInfo
	fan	MX,(1)
.stabn 2323, LineInfo
	jp	nz,MTimeSet2		; br to check the hold time
	
.stabn 2325, 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 2332, LineInfo
	call	ClrKeyVar
.stabn 2333, LineInfo
	ld	a,(M2)
.stabn 2334, LineInfo
	cp	a,0x01
.stabn 2335, LineInfo
	jp	nz,HTimeSet0
.stabn 2336, LineInfo
	ld	a,0
.stabn 2337, LineInfo
	ld	(M2),a
.stabn 2338, LineInfo
	jp	TimeSet0
HTimeSet0:
.stabn 2340, LineInfo
	call	IncSetMinute
	; add by hcy 03-11-29 11:40
.stabn 2342, LineInfo
	call	SetTmr1s
.stabn 2343, LineInfo
	jp	TimeSet0
MTimeSet2:
	
;
; starting from here if the key hold time > 2 seconds
;
.stabn 2349, LineInfo
	OR	MX,(4)
.stabn 2350, LineInfo
	ld	a,(M0)
.stabn 2351, LineInfo
	cp	a,0x0f		; tolerance  -1/8 sec
.stabn 2352, LineInfo
	jp	nz,TimeSet0	; br if Hold time < 2 seconds
.stabn 2353, LineInfo
	ld	a,0x01
.stabn 2354, LineInfo
	ld	(M2),a
.stabn 2355, LineInfo
	ld	a,0x0d
.stabn 2356, LineInfo
	ld	(M0),a	; 
.stabn 2357, LineInfo
	jp	HTimeSet0

MTimeSet0:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2362, LineInfo
	call	ReloadTmr2Min
.stabn 2363, LineInfo
	call	ClrKeyVar
.stabn 2364, LineInfo
	ld	a,7
.stabn 2365, LineInfo
	ld	x,0x0a1
.stabn 2366, LineInfo
	calz	DspPattern1		; ' ' 	
	
;	ORG	300H
	
TimeSet4:
.stabn 2371, LineInfo
	calz	FlashTimeFormat
.stabn 2372, LineInfo
	call	ChkTimer
	
.stabn 2374, LineInfo
	ld	a,(M5)
.stabn 2375, LineInfo
	fan	a,0b1111
.stabn 2376, LineInfo
	jp	z,NewE
	
.stabn 2378, LineInfo
	LD	A,(M3)
.stabn 2379, LineInfo
	CP	A,(0b1101)
.stabn 2380, LineInfo
	JP	z,TTimeSet0	;; jmp to exit setting
.stabn 2381, LineInfo
	CP	A,(0b1011)
.stabn 2382, LineInfo
	jp	z,TTimeSet1	; jmp to toggle time format
.stabn 2383, LineInfo
	jp	TimeSet4
	
TTimeSet1:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2388, LineInfo
	call	ReloadTmr2Min
.stabn 2389, LineInfo
	ld	X,(1)
.stabn 2390, LineInfo
	fan	MX,(1)
.stabn 2391, LineInfo
	jp	nz,TimeSet4		; br to check the hold time
	
.stabn 2393, LineInfo
	AND	MX,0x0f-(2)	; clr the key
.stabn 2394, LineInfo
	call	ClrKeyVar
.stabn 2395, LineInfo
	ld	x,(1)
.stabn 2396, LineInfo
	xor	mx,(8)
.stabn 2397, LineInfo
	calz	DspTimeFormat
.stabn 2398, LineInfo
	jp	TimeSet4

TTimeSet0:
;	ld	a,15
;	ld	Tmr15s,a
.stabn 2403, LineInfo
	call	ReloadTmr2Min
.stabn 2404, LineInfo
	ld	x,(0x18)
.stabn 2405, LineInfo
	ld	y,(0x12) 
.stabn 2406, LineInfo
	call	Copy2Byte	; 
.stabn 2407, LineInfo
	ld	x,(0x10)
.stabn 2408, LineInfo
	call	ClrByte
.stabn 2409, LineInfo
	ld	y,(0x14)
.stabn 2410, LineInfo
	calz	DspHour
.stabn 2411, LineInfo
	ld	y,(0x12)
.stabn 2412, LineInfo
	calz	DspMinute
.stabn 2413, LineInfo
	ld	X,(1)
.stabn 2414, LineInfo
	AND	MX,0x0f-(2)	; clr the key
.stabn 2415, LineInfo
	call	ClrKeyVar
.stabn 2416, LineInfo
	jp	ProgStartLp
	
NewE:
.stabn 2419, LineInfo
	ld	x,(1)
.stabn 2420, LineInfo
	and	mx,0x0f-(2)
.stabn 2421, LineInfo
	call	ClrKeyVar
.stabn 2422, LineInfo
	jp	ProgStart	

;
;	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 ti

⌨️ 快捷键说明

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