📄 r08cnvlcdclk1.ms
字号:
cp my,0x0B
.stabn 1547, LineInfo
jp z,IsEquEE
.stabn 1548, LineInfo
scf
.stabn 1549, LineInfo
ret
IsEquEE:
.stabn 1551, LineInfo
rcf
.stabn 1552, LineInfo
ret
Init:
.stabn 1555, LineInfo
DI ; reset interrupt mask
.stabn 1556, LineInfo
RST F,0b0011
; LD A,0
; LD xp,a ; reset XP
; LD YP,A
.stabn 1561, LineInfo
LD A,0x0f ; define SP
.stabn 1562, LineInfo
LD B,0x04
.stabn 1563, LineInfo
LD SPL,A
.stabn 1564, LineInfo
LD SPH,B
;
.stabn 1566, LineInfo
NOP5
.stabn 1567, LineInfo
NOP5
.stabn 1569, LineInfo
ld a,0x02
.stabn 1570, LineInfo
ld xp,a
.stabn 1571, LineInfo
ld yp,a
;
; Cold start from here
;
.stabn 1575, LineInfo
call LCDClr
; LD x,90h
;LCDClr0:
; ldpx mx,0
; cp xh,0bh ; LCD ram from 90 to AFH
; jp nz, LCDClr0
;
; Check the warm start words if necessary
;
;
; clr RAM for Cold start here
.stabn 1587, LineInfo
ld x,0
RAMClr:
.stabn 1589, LineInfo
ldpx mx,0
.stabn 1590, LineInfo
cp xh,4
.stabn 1591, LineInfo
jp nz,RAMClr
;
; set time to 12:00 after cold start
;
.stabn 1595, LineInfo
ld x,(0x14)
; ldpx mx,2 ; hour=12, min/sec cleared by RAMCLr
; ldpx mx,1 ; default 12:00 p.m.
.stabn 1599, LineInfo
ldpx mx,0
.stabn 1600, LineInfo
ldpx mx,0 ; default 12:00 a.m.
;
; define I/O port
.stabn 1603, LineInfo
LD Y,(0x0EE)
.stabn 1604, LineInfo
LD MY,0b0000 ; P-port as input
;
.stabn 1606, LineInfo
LD Y,(0x0EB)
; 03-11-22 14:04 HCY
; LD MY,0010b ; Power down, CLK_IN default high
.stabn 1609, LineInfo
LD MY,0b0000 ; POWER DOWN ,CLK_IN LOW
;
;
;
; enable interrupts if any
;
.stabn 1617, LineInfo
LD Y,(0x0E5)
.stabn 1618, LineInfo
LD MY,0b0100 ; No key interrupt allowed, only the D_Clk
;
.stabn 1620, LineInfo
LD Y,(0x0E8)
.stabn 1621, LineInfo
LD MY,0b0000 ; No timer interrupt allowed
;
.stabn 1623, LineInfo
LD Y,(0x0EE) ; reset timer
.stabn 1624, LineInfo
LD MY,0b0100
;
.stabn 1626, LineInfo
ld y,(0x1c)
.stabn 1627, LineInfo
ld my,0
.stabn 1628, LineInfo
ld y,(0x17)
.stabn 1629, LineInfo
ld my,0x04
;
.stabn 1631, LineInfo
ld y,(0x31)
; ld my,WEIGHTMODE
.stabn 1633, LineInfo
ld my,(0)
.stabn 1635, LineInfo
ld x,(0x30)
.stabn 1636, LineInfo
ld mx,0x0d ; total receive 13 nibble data
.stabn 1638, LineInfo
LD a,0
.stabn 1639, LineInfo
ld (M0),a ;
.stabn 1641, LineInfo
jp ProgStart
; ; for test
; ld x,RxIcon0
; ld a,0fh
; ld mx,a
; inc x
; ld mx,a
; inc x
; ld mx,a
; inc x
; ld mx,a
; call DspIcons
;
; EI
;
; end of initialization
; c =1 if not press'on and off' or 'on and kg'
; c =0 if enter calibrate mode
;ChkCalibrateMode:
; ld x,KPort
; fan mx,IO_Key_On
; jp z,Calib0 ; jmp if key_on is not pressed
;
; ld B,Key_OnOff
; fan mx,IO_Key_Off
; jp nz,CalKey0 ; br if Key_off is preseed
;;
; ld b,Key_OnKg
; ld x,PPort
; fan mx,IO_Key_Kg
; jp z,Calib0 ; br if Key_Kg is not preseed
;CalKey0:
; call LCDClr
; call TurnOnLCD
; call Dly125ms
; ld x,KPort
; fan mx,IO_Key_On
; jp nz,CalKey0 ; jmp if key_on is hold
;
; LD Y,RPort
; ; 03-11-22 14:04 HCY
; LD MY,0011b ; Power on, CLK_IN default high
; call Dly125ms
; call Dly125ms
;
; ld x,ModeOpt
; ld mx,CALIBRATEMODE
;
;WaitSend0:
; ld x,KPort
; fan mx,0100b
; jp nz,WaitSend0 ; BR IF D_CLK is high
;
; LD KeyCode,B
; call SendCalKey
;
; ; remark by hcy 03-11-26 10:22
; ; turn on all segment
;TurnOnLCD:
; LD x,40h
;LCDClrf:
; ldpx mx,0fh
; cp xh,07h ; LCD ram from 90 to AFH
; jp nz, LCDClrf
; call Dly250
; call LCDClr
; rcf
; ret
;Calib0:
; scf
; ret
;
;
; Interrupt handling routines
;------------------------------------------------------
; RTC interrupt routine, 0.5 seconds/intr
IntRTC:
; Push A
; push F
;
; pop F
; POP A
; EI ; because I is reset when jumping into ISR
.stabn 1727, LineInfo
RET
;------------------------------------------------------
; Key port interrupt routine
IntKPort:
; PUSH F
; PUSH A
; PUSH YL
; PUSH YH
;IntKPort0:
; ld Y,KIntFactor
; ld a,my ; read and clear the IRQ
; LD Y,RPort
; and my,1101b ; Pull down CLK_IN to ready receive data
; rcf
; ld Y,PPort
; fan my,1000b ; only remain P0.3
; jp z,IntK0
; scf
;IntK0:
; ld y,CommBufferL
; rrc my
; ld y,CommCount
; rcf
; sbc my,1
; jp nz,IntK1
; ld y,AppFlags
; or my,Rx4BitFlag ; set the 'rx4bitflag'
;
; calz ToDoubleBuffer
; calz ReloadCommVar
;IntK1:
; LD Y,RPort
; or my,0010b ; Pull up CLK_IN to ready receive data
; POP YH
; POP YL
; POP A
; POP F
; EI ; because I is reset when jumping into ISR
.stabn 1769, LineInfo
RET
GetIcons:
.stabn 1772, LineInfo
rrc a
.stabn 1773, LineInfo
ld (M7),a
.stabn 1774, LineInfo
ld a,0
.stabn 1775, LineInfo
rlc a
.stabn 1776, LineInfo
ld (M6),a
.stabn 1777, LineInfo
ret
;-------------------------------------
; 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
.stabn 1798, LineInfo
LD A,0x0a
.stabn 1799, LineInfo
CALL Send4Bit
; Check the time out if neccessary
; ld x,RegKeyCode
; ld a,mx
.stabn 1804, LineInfo
ld a,(M3)
.stabn 1805, LineInfo
CALL Send4Bit
;
.stabn 1807, LineInfo
ld y,(0x0EB) ; set D_Out Hi after sending
; or my,0010b
.stabn 1809, LineInfo
or my,0b0011
; Check the time out if neccessary
.stabn 1811, LineInfo
RET
;-------------------------------------------------------
; Key port and RTC interrupt happened at the same time
;
;=========================================================
.org 0x0200
ProgStart:
.stabn 1820, LineInfo
ld y,(0x31)
.stabn 1821, LineInfo
fan my,0b1111
.stabn 1822, LineInfo
jp nz,ProgStartLp ; jmp if not clock mode
.stabn 1823, LineInfo
ld y,(0x14)
.stabn 1824, LineInfo
calz DspHour
.stabn 1825, LineInfo
ld y,(0x12)
.stabn 1826, LineInfo
calz DspMinute
ProgStartLp:
.stabn 1828, LineInfo
ld x,(0x0E9)
.stabn 1829, LineInfo
ld a,mx ; read and clear any interrupt request flags
.stabn 1830, LineInfo
fan a,0b0010 ; chk 1/8 sec
.stabn 1831, LineInfo
jp z,ProgStartLp0
.stabn 1832, LineInfo
ld b,(M3)
.stabn 1833, LineInfo
cp b,(0b1101)
.stabn 1834, LineInfo
jp nz,ProgStartLp0
.stabn 1835, LineInfo
inc (M0) ; inc the keyhold time
ProgStartLp0:
.stabn 1838, LineInfo
fan a,0b0100 ; chk 1/2 sec
.stabn 1839, LineInfo
jp nz,UpdateSecond
ProgStartComm:
.stabn 1842, LineInfo
ld x,(0x31)
.stabn 1843, LineInfo
cp mx,(0)
.stabn 1844, LineInfo
jp z,xProgStartComm ; no comm in clock mode
.stabn 1847, LineInfo
LD X,(0x16)
.stabn 1848, LineInfo
FAN MX,(4)
.stabn 1849, LineInfo
JP z,Comm_Rx
; add these by hcy 03-11-22 10:32
; ld a,CommFlag
; fan a,1111b
; jp nz,Comm_Rx ; jmp if receiving
; add these by hcy 03-11-19 10:50
.stabn 1856, LineInfo
call SendKeyData
; remark 03-11-22 11:55
; jp ProgStartComm
;
; Send the data after receiving a command
; remark it by hcy 03-11-13 16:30 for test communication
; ld x,KPort
; fan mx,0100b ; chk CLK pin
; jp nz,Comm_Rx ; clk hi-> data send from Samsung
; LD X,RPort
; LD MX,0001b ; D_out low
; CALL SendKey
; LD X,AppFlags
; AND MX,0fh-ReqToSendFlag ; clear the flag after sending
Comm_Rx:
; remark it by hcy 03-11-13 16:32 for test communication
; remark for new keyboard
; ld x,KPort
; fan mx,0100b
.stabn 1880, LineInfo
ld x,(0x0ED)
.stabn 1881, LineInfo
fan mx,0b0001
.stabn 1882, LineInfo
jp z,xProgStartComm ; BR IF low EDGE
; ld Y,KIntFactor
; ld a,my ; read nad clear the IRQ
; fan a,0100b ; chk K02
; jp z,NewProg0
; find a rising edge
; ld a,1
; ld CommFlag,a ; 1--> commflag when receiving
.stabn 1894, LineInfo
LD Y,(0x0EB)
.stabn 1895, LineInfo
and my,0b0001 ; Pull down CLK_IN to ready receive data
; remark by hcy for new keyboard
; ld Y,PPort
; ld a,my
; rlc a
; add hcy for new keyboard
.stabn 1903, LineInfo
ld Y,(0x0ED)
.stabn 1904, LineInfo
ld a,my
.stabn 1905, LineInfo
rrc a
.stabn 1906, LineInfo
rrc a ; p0.1 --> c
.stabn 1908, LineInfo
ld y,(0x1c)
.stabn 1909, LineInfo
rrc my ; load data in buffer
.stabn 1911, LineInfo
LD Y,(0x0EB)
; or my,0010b ; Pull up CLK_IN to ready receive data
.stabn 1913, LineInfo
or my,0b0011 ; if '0010b' 0--> r00,
.stabn 1915, LineInfo
ld y,(0x17) ; dec count
.stabn 1916, LineInfo
ADD my,0x0F ;
.stabn 1917, LineInfo
jp nz,ProgStartLp ; don't chk key until end of a nibble
.stabn 1919, LineInfo
CALl ToRecBuffer
.stabn 1920, LineInfo
call ReloadCommVar
.stabn 1921, LineInfo
ld x,(0x1d)
.stabn 1922, LineInfo
add mx,1
.stabn 1924, LineInfo
ld x,(0x1d)
.stabn 1925, LineInfo
cp mx,1
.stabn 1926, LineInfo
jp nz,Prog3 ; jmp if not finish receiving start code
.stabn 1927, LineInfo
call IsEquStartCode
.stabn 1928, LineInfo
jp nc,xProgStartComm ; jmp if equ start code
; add by hcy 03-11-25 17:36
.stabn 1931, LineInfo
cp my,0x0D
.stabn 1932, LineInfo
jp z,TurnOffPwr
; error case
.stabn 1935, LineInfo
jp CommE ; give up this communication
Prog3:
; remark by hcy 03-11-20 10:34
; cp mx,2
; jp nz,Prog4 ; jmp if not or already finish receiving command
; calz IsRightCmd
; jp nc,xProgStartComm
; error case
; jp CommE ; give up this communication
Prog4:
; jp c,xProgStartComm ; jmp if not finish receiving command
.stabn 1947, LineInfo
ld x,(0x30)
.stabn 1948, LineInfo
add mx,0x0f ; -1
.stabn 1949, LineInfo
jp nz,xProgStartComm ; jmp if not receive all data
; completely received a command
.stabn 1951, LineInfo
ld x,(0x30)
.stabn 1952, LineInfo
ld mx,0x0d ; total receive 13 nibble data
.stabn 1954, LineInfo
LD X,(0x16)
.stabn 1955, LineInfo
FAN MX,(4)
.stabn 1956, LineInfo
JP z,Prog5 ; br if no send request
Comm_Tx:
.stabn 1959, LineInfo
call SendKeyData
;
Prog5:
.stabn 1962, LineInfo
call DspWeight
.stabn 1963, LineInfo
call DspIcons
.stabn 1964, LineInfo
call DspFraction
CommE:
.stabn 1967, LineInfo
ld x,(0x1d)
.stabn 1968, LineInfo
ld mx,0
; JP xProgStartComm
;----------------------------------------
xProgStartComm:
;
; here for checking the keyboard
;
; add by hcy 03-12-4 11:02 for calibrate mode
.stabn 1977, LineInfo
call ChkCalibrateMode
.stabn 1978, LineInfo
jp nc,ProgStart ; jmp if enter calibrate mode
.stabn 1980, LineInfo
CALl KeyScan
.stabn 1981, LineInfo
LD X,(1)
.stabn 1982, LineInfo
FAN MX,(2)
.stabn 1983, LineInfo
jp z,ProgStartLp ; br if no key pressed before
;
.stabn 1985, LineInfo
JP Main_KeyHandle ; br if key press-hold and release
;
; Flash the colon per 0.5 second
;
UpdateSecond:
; add by hcy 03-12-4 14:19
.stabn 1991, LineInfo
ld a,(M9)
.stabn 1992, LineInfo
fan a,0b1111
.stabn 1993, LineInfo
jp z,UpdateS0
.stabn 1994, LineInfo
dec (M9)
UpdateS0:
.stabn 1996, LineInfo
call ToggleHalfSecFlag
.stabn 1998, LineInfo
calz FlashColon
.stabn 2000, LineInfo
ld x,(0x16)
.stabn 2001, LineInfo
fan mx,(2)
.stabn 2002, LineInfo
jp z,ProgStartComm ; br if just 0.5 sec
;
.stabn 2004, LineInfo
and mx,0x0f-(2) ; clear the bit
; update the clock per 1 min
;
.stabn 2007, LineInfo
calz IncSecond
.stabn 2008, LineInfo
jp nc,ProgStartComm ; No display update if change in second only
.stabn 2009, LineInfo
calz IncMinute
; jp nc,xUpdateClk
.stabn 2011, LineInfo
jp nc,ProgStart
.stabn 2012, LineInfo
calz IncHour
xUpdateClk:
;
; depends on which mode to show the time
;
; remark by hcy 03-11-20 19:41
.stabn 2018, LineInfo
jp ProgStart
; add by hcy 03-11-20 19:41
; jp ProgStartLp
;-------------------------------------
; 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
;SetTmr1s:
; ld x,RegKeyFlags
; or mx,DisFlashFlag ; disable flash
; ld a,2
; ld Tmr1s,a
; ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -