📄 cnvlcdclk.ms
字号:
;
.stabn 1527, LineInfo
NOP5
.stabn 1528, LineInfo
NOP5
;
; Cold start from here
;
.stabn 1532, 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 1544, LineInfo
ld x,0
RAMClr:
.stabn 1546, LineInfo
ldpx mx,0
.stabn 1547, LineInfo
cp xh,5
.stabn 1548, LineInfo
jp nz,RAMClr
;
; set time to 12:00 after cold start
;
.stabn 1552, LineInfo
ld x,(0x14)
.stabn 1553, LineInfo
ldpx mx,2 ; hour=12, min/sec cleared by RAMCLr
.stabn 1554, LineInfo
ldpx mx,1
;
; define I/O port
.stabn 1557, LineInfo
LD Y,(0x0FC)
.stabn 1558, LineInfo
LD MY,0b0000 ; P-port as input
;
.stabn 1560, LineInfo
LD Y,(0x0F3)
; 03-11-22 14:04 HCY
.stabn 1562, LineInfo
LD MY,0b0010 ; Power down, CLK_IN default high
;
;
;
; enable interrupts if any
;
.stabn 1570, LineInfo
LD Y,(0x0E8)
.stabn 1571, LineInfo
LD MY,0b0100 ; No key interrupt allowed, only the D_Clk
;
.stabn 1573, LineInfo
LD Y,(0x0EB)
.stabn 1574, LineInfo
LD MY,0b0000 ; No timer interrupt allowed
;
.stabn 1576, LineInfo
LD Y,(0x0F9) ; reset timer
.stabn 1577, LineInfo
LD MY,0b0100
;
.stabn 1579, LineInfo
ld y,(0x1c)
.stabn 1580, LineInfo
ld my,0
.stabn 1581, LineInfo
ld y,(0x17)
.stabn 1582, LineInfo
ld my,0x04
;
.stabn 1584, LineInfo
ld y,(0x31)
; ld my,WEIGHTMODE
.stabn 1586, LineInfo
ld my,(0)
.stabn 1588, LineInfo
ld x,(0x30)
.stabn 1589, LineInfo
ld mx,0x0d ; total receive 13 nibble data
; ; 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
.stabn 1607, LineInfo
ld x,(0x0E0)
.stabn 1608, LineInfo
fan mx,(1)
.stabn 1609, LineInfo
jp z,ProgStart ; jmp if key_on is not pressed
.stabn 1611, LineInfo
ld B,(0b0110)
.stabn 1612, LineInfo
fan mx,(2)
.stabn 1613, LineInfo
jp nz,CalKey0 ; br if Key_off is preseed
;
.stabn 1615, LineInfo
ld b,(0b0101)
.stabn 1616, LineInfo
ld x,(0x0F6)
.stabn 1617, LineInfo
fan mx,(1)
.stabn 1618, LineInfo
jp z,ProgStart ; br if Key_Kg is not preseed
CalKey0:
; LD Y,RPort
; ; 03-11-22 14:04 HCY
; LD MY,0011b ; Power on, CLK_IN default high
; call Dly125ms
; call Dly125ms
.stabn 1626, LineInfo
call TurnOnPwr
.stabn 1628, LineInfo
ld x,(0x31)
.stabn 1629, LineInfo
ld mx,(2)
WaitSend0:
.stabn 1632, LineInfo
ld x,(0x0E0)
.stabn 1633, LineInfo
fan mx,0b0100
.stabn 1634, LineInfo
jp nz,WaitSend0 ; BR IF D_CLK is high
.stabn 1636, LineInfo
LD (M3),B
.stabn 1637, LineInfo
call SendCalKey
; remark by hcy 03-11-26 10:22
; turn on all segment
.stabn 1642, LineInfo
LD x,0x90
LCDClrf:
.stabn 1644, LineInfo
ldpx mx,0x0f
.stabn 1645, LineInfo
cp xh,0x0b ; LCD ram from 90 to AFH
.stabn 1646, LineInfo
jp nz, LCDClrf
.stabn 1648, LineInfo
call Dly250
.stabn 1649, LineInfo
call LCDClr
.stabn 1650, LineInfo
jp ProgStart
;
;
; Interrupt handling routines
;------------------------------------------------------
; RTC interrupt routine, 0.5 seconds/intr
IntRTC:
; Push A
; push F
;
; pop F
; POP A
.stabn 1662, LineInfo
EI ; because I is reset when jumping into ISR
.stabn 1663, 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
.stabn 1704, LineInfo
EI ; because I is reset when jumping into ISR
.stabn 1705, LineInfo
RET
GetIcons:
.stabn 1708, LineInfo
rrc a
.stabn 1709, LineInfo
ld (M7),a
.stabn 1710, LineInfo
ld a,0
.stabn 1711, LineInfo
rlc a
.stabn 1712, LineInfo
ld (M6),a
.stabn 1713, 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 1734, LineInfo
LD A,0x0a
.stabn 1735, LineInfo
CALL Send4Bit
; Check the time out if neccessary
.stabn 1737, LineInfo
LD X,(3)
.stabn 1738, LineInfo
LD A,MX
.stabn 1739, LineInfo
CALL Send4Bit
;
.stabn 1741, LineInfo
ld y,(0x0F3) ; set D_Out Hi after sending
; or my,0010b
.stabn 1743, LineInfo
or my,0b0011
; Check the time out if neccessary
.stabn 1745, LineInfo
RET
;-------------------------------------------------------
; Key port and RTC interrupt happened at the same time
;
;=========================================================
.org 0x0200
ProgStart:
.stabn 1754, LineInfo
ld y,(0x31)
.stabn 1755, LineInfo
fan my,0b1111
.stabn 1756, LineInfo
jp nz,ProgStartLp ; jmp if not clock mode
.stabn 1757, LineInfo
ld y,(0x14)
.stabn 1758, LineInfo
calz DspHour
.stabn 1759, LineInfo
ld y,(0x12)
.stabn 1760, LineInfo
calz DspMinute
ProgStartLp:
.stabn 1762, LineInfo
ld x,(0x0EF)
.stabn 1763, LineInfo
ld a,mx ; read and clear any interrupt request flags
.stabn 1764, LineInfo
fan a,0b0010 ; chk 1/8 sec
.stabn 1765, LineInfo
jp z,ProgStartLp0
.stabn 1766, LineInfo
ld b,(M3)
.stabn 1767, LineInfo
cp b,(0b1101)
.stabn 1768, LineInfo
jp nz,ProgStartLp0
.stabn 1769, LineInfo
inc (M0) ; inc the keyhold time
ProgStartLp0:
.stabn 1772, LineInfo
fan a,0b0100 ; chk 1/2 sec
.stabn 1773, LineInfo
jp nz,UpdateSecond
ProgStartComm:
.stabn 1776, LineInfo
ld x,(0x31)
.stabn 1777, LineInfo
cp mx,(0)
.stabn 1778, LineInfo
jp z,xProgStartComm ; no comm in clock mode
.stabn 1781, LineInfo
LD X,(0x16)
.stabn 1782, LineInfo
FAN MX,(4)
.stabn 1783, 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 1790, 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
.stabn 1810, LineInfo
ld x,(0x0E0)
.stabn 1811, LineInfo
fan mx,0b0100
.stabn 1812, 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 1824, LineInfo
LD Y,(0x0F3)
.stabn 1825, LineInfo
and my,0b0001 ; Pull down CLK_IN to ready receive data
.stabn 1826, LineInfo
ld Y,(0x0F6)
.stabn 1827, LineInfo
ld a,my
.stabn 1828, LineInfo
rlc a
.stabn 1830, LineInfo
ld y,(0x1c)
.stabn 1831, LineInfo
rrc my ; load data in buffer
.stabn 1833, LineInfo
LD Y,(0x0F3)
; or my,0010b ; Pull up CLK_IN to ready receive data
.stabn 1835, LineInfo
or my,0b0011 ; if '0010b' 0--> r00,
.stabn 1837, LineInfo
ld y,(0x17) ; dec count
.stabn 1838, LineInfo
ADD my,0x0F ;
.stabn 1839, LineInfo
jp nz,ProgStartLp ; don't chk key until end of a nibble
.stabn 1841, LineInfo
CALl ToRecBuffer
.stabn 1842, LineInfo
call ReloadCommVar
.stabn 1843, LineInfo
ld x,(0x1d)
.stabn 1844, LineInfo
add mx,1
.stabn 1846, LineInfo
ld x,(0x1d)
.stabn 1847, LineInfo
cp mx,1
.stabn 1848, LineInfo
jp nz,Prog3 ; jmp if not finish receiving start code
.stabn 1849, LineInfo
call IsEquStartCode
.stabn 1850, LineInfo
jp nc,xProgStartComm ; jmp if equ start code
; add by hcy 03-11-25 17:36
.stabn 1853, LineInfo
cp my,0x0D
.stabn 1854, LineInfo
jp z,TurnOffPwr
; error case
.stabn 1857, 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 1869, LineInfo
ld x,(0x30)
.stabn 1870, LineInfo
add mx,0x0f ; -1
.stabn 1871, LineInfo
jp nz,xProgStartComm ; jmp if not receive all data
; completely received a command
.stabn 1873, LineInfo
ld x,(0x30)
.stabn 1874, LineInfo
ld mx,0x0d ; total receive 13 nibble data
; ld a,0
; ld CommFlag,a ; 0--> commflag when finish receiving
.stabn 1879, LineInfo
LD X,(0x16)
.stabn 1880, LineInfo
FAN MX,(4)
.stabn 1881, LineInfo
JP z,Prog5 ; br if no send request
; LD X,RPort
; LD MX,0001b ; D_out low
Comm_Tx:
; Send the data after receiving a command
; CALL SendKey
; LD X,AppFlags
; AND MX,0fh-ReqToSendFlag ; clear the flag after sending
.stabn 1892, LineInfo
call SendKeyData
;
Prog5:
.stabn 1895, LineInfo
call DspWeight
.stabn 1896, LineInfo
call DspIcons
.stabn 1897, LineInfo
call DspFraction
CommE:
.stabn 1899, LineInfo
ld x,(0x1d)
.stabn 1900, LineInfo
ld mx,0
.stabn 1901, LineInfo
JP xProgStartComm
;----------------------------------------
xProgStartComm:
;
; here for checking the keyboard
;
.stabn 1907, LineInfo
CALl KeyScan
.stabn 1908, LineInfo
LD X,(1)
.stabn 1909, LineInfo
FAN MX,(2)
.stabn 1910, LineInfo
jp z,ProgStartLp ; br if no key pressed before
;
.stabn 1912, LineInfo
JP Main_KeyHandle ; br if key press-hold and release
;
; Flash the colon per 0.5 second
;
UpdateSecond:
.stabn 1918, LineInfo
call ToggleHalfSecFlag
.stabn 1920, LineInfo
calz FlashColon
;
.stabn 1922, LineInfo
ld x,(0x16)
.stabn 1923, LineInfo
fan mx,(2)
.stabn 1924, LineInfo
jp z,ProgStartComm ; br if just 0.5 sec
;
.stabn 1926, LineInfo
and mx,0x0f-(2) ; clear the bit
; update the clock per 1 min
;
.stabn 1929, LineInfo
calz IncSecond
.stabn 1930, LineInfo
jp nc,ProgStartComm ; No display update if change in second only
.stabn 1931, LineInfo
calz IncMinute
.stabn 1932, LineInfo
jp nc,xUpdateClk
.stabn 1933, LineInfo
calz IncHour
xUpdateClk:
;
; depends on which mode to show the time
;
; remark by hcy 03-11-20 19:41
.stabn 1939, 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:
.stabn 1953, LineInfo
ld y,0
Dlym1:
.stabn 1955, LineInfo
inc y
.stabn 1956, LineInfo
cp yh,0x02
.stabn 1957, LineInfo
jp nz,Dlym1
.stabn 1958, LineInfo
ret
SetTmr1s:
.stabn 1961, LineInfo
ld x,(1)
.stabn 1962, LineInfo
or mx,(4) ; disable flash
.stabn 1963, LineInfo
ld a,2
.stabn 1964, LineInfo
ld (M8),a
.stabn 1965, LineInfo
ret
ClrSetTimeVar:
.stabn 1968, LineInfo
ld X,(1)
.stabn 1969, LineInfo
AND MX,0x0f-(4) ; clr the key
ClrKeyVar:
.stabn 1971, LineInfo
LD a,0
.stabn 1972, LineInfo
ld (M3),a ; clr the key code
ClrKeyHoldTm:
.stabn 1974, LineInfo
ld a,0
.stabn 1975, LineInfo
ld (M0),a ; reset timer
.stabn 1976, LineInfo
ret
;-------------------------------------
; Cate : Delay
; By : Hcy
; Func : delay 125ms
; Desc : Dly125ms
; I/P : --
; O/P : --
; Destroy:
; Note :
;
Dly125ms:
.stabn 1989, LineInfo
ld x,0
Dlym0:
.stabn 1991, LineInfo
inc x
.stabn 1992, LineInfo
cp xh,0x0f
.stabn 1993, LineInfo
jp nz,Dlym0
.stabn 1994, LineInfo
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -