📄 em78p153s-led.dt
字号:
;******************************************************;
; ;
; Tilte: EM78x153x include file ;
;
;======================================================;
; Registers R0~R2F ;
;======================================================;
;------------------------------------------------------
;---REGISTER DEFINE---
R0 EQU 0X00 ; R0/IAR: Indirect Address Register
DF EQU 0X00
IAR EQU 0X00
R1 EQU 0X01 ; R1/TCC: Time Clock/Counter
RTCC EQU 0X01
RTCC_VALUE EQU 0X01
R2 EQU 0X02
PC EQU 0X02
STATUS EQU 0X03 ; R3/SR: Status Register
R3 EQU 0X03
_RST == 7 ; Bit for reset type
; Set to 1 if wake-up from sleep mode on pin change
; Set to 0 if wake-up from other reset types
_GP1 == 6 ; General purpose read/write bits
_GP0 == 5 ; General purpose read/write bits
_T == 4 ; Time-out bit
_P == 3 ; Power down bit
_Z == 2 ; Zero flag
_DC == 1 ; Auxiliary carry flag
_C == 0 ; Carry flag
R4 EQU 0X04
RAM_ADDRESS EQU 0X04
FSR EQU 0X04 ; Bits 0~5 select registers (address: 00~3F) in the indirect address mode.
; Bit 7.6 is a general-purpose read/write bit.
R5 EQU 0X05 ; Port 5 data Register
PORT5 EQU 0X05
P5 EQU 0X05
R6 EQU 0X06 ; Port 6 data Register
PORT6 EQU 0X06
_CLOCK == 6
_STROBE == 7
_DATA == 1
RF EQU 0X0F ; RF/ISR: Interrupt Status Register
_EXIF == 2 ; External interrupt flag
_ICIF == 1 ; Port 6 input status change interrupt flag
_TCIF == 0 ; TCC overflow interrupt flag
;CONT: Control Register
_INT == 6 ; Interrupt enable flag
; "0" : Masked by DISI or hardware interrupt
; "1" : Enabled by ENI/RETI instructions
_TS == 5 ; TCC signal source
; "0" : Internal instruction cycle clock
; "1" : Transition on TCC pin
_TE == 4 ; TCC signal edge
; "0" : Increment if the transition from low to high takes place on TCC pin
; "1" : Increment if the transition from high to low takes place on TCC pin
_PAB == 3 ; Prescaler assignment bit
; "1" : TCC assign to WDT
; "0" : TCC assign to TCC
_PSR2 == 2
_PSR1 == 1
_PSR0 == 0 ; (PSR0~PSR2): TCC/WDT prescaler Select bits
; |------|------|------|----------|----------|
; | PSR2 | PSR1 | PSR0 | TCC Rate | WDT Rate |
; |------|------|------|----------|----------|
; | 0 | 0 | 0 | 1:2 | 1:1 |
; | 0 | 0 | 1 | 1:4 | 1:2 |
; | 0 | 1 | 0 | 1:8 | 1:4 |
; | 0 | 1 | 1 | 1:16 | 1:8 |
; | 1 | 0 | 0 | 1:32 | 1:16 |
; | 1 | 0 | 1 | 1:64 | 1:32 |
; | 1 | 1 | 0 | 1:128 | 1:64 |
; | 1 | 1 | 1 | 1:256 | 1:128 |
; | -----|------|------|----------|----------|
IOC5 EQU 0X05 ; PORT 5 I/O Port Control Register
IOC6 EQU 0X06
; Bit[n]= "1" , Set P6[n] as input pin, n=7~0
; Bit[n]= "0" , Set P6[n] as output pin, n=7~4,2~0
mIOC67 == 0x80 ;
mIOC66 == 0x40 ;
mIOC65 == 0x20 ;
mIOC64 == 0x10 ;
mIOC63 == 0x08 ; P63 is input only.
mIOC62 == 0x04 ;
mIOC61 == 0x02 ;
mIOC60 == 0x01 ;
IOCB EQU 0X0B ; IOCB/PCR: Port 5 and P6 Pull-down Control Register
; "0": Enable internal pull-down
; "1": Disable internal pull-dowm
; Bit 7 not used
_P62D == 6 ; Control bit is used to enable the pull-down of P62 pin
_P61D == 5 ; Control bit is used to enable the pull-down of P61 pin
_P60D == 4 ; Control bit is used to enable the pull-down of P60 pin
; Bit 3 not used
_P52D == 2 ; Control bit is used to enable the pull-down of P52 pin
_P51D == 1 ; Control bit is used to enable the pull-down of P51 pin
_P50D == 0 ; Control bit is used to enable the pull-down of P50 pin
IOCC EQU 0X0C ; IOCC/ODCR: Port 6 Open-drain Control Register
; Bit[n]= "0" , Disable P6[n] Open-Drain Function.n=7~4,2~0
; Bit[n]= "1" , Enable P6[n] Open-Drain Function.n=n=7~4,2~0
_P67O == 7 ; Control bit is used to enable the open-drain of P67 pin
_P66O == 6 ; Control bit is used to enable the open-drain of P66 pin
_P65O == 5 ; Control bit is used to enable the open-drain of P65 pin
_P64O == 4 ; Control bit is used to enable the open-drain of P64 pin
; Bit 3 not used
_P62O == 2 ; Control bit is used to enable the open-drain of P62 pin
_P61O == 1 ; Control bit is used to enable the open-drain of P61 pin
_P60O == 0 ; Control bit is used to enable the open-drain of P60 pin
IOCD EQU 0X0D ; IOCD/PHCR: Port 6 Pull-high Control Register
; Bit[n]= "0" , Enable P6[n] Pull High Function.n=7~4,2~0
; Bit[n]= "1" , disable P6[n] Pull High Function.n=7~4,2~0
_P67H == 7 ; Control bit is used to enable the pull-high of P67 pin
_P66H == 6 ; Control bit is used to enable the pull-high of P66 pin
_P65H == 5 ; Control bit is used to enable the pull-high of P65 pin
_P64H == 4 ; Control bit is used to enable the pull-high of P64 pin
; Bit 3 not used
_P62H == 2 ; Control bit is used to enable the pull-high of P62 pin
_P61H == 1 ; Control bit is used to enable the pull-high of P61 pin
_P60H == 0 ; Control bit is used to enable the pull-high of P60 pin
IOCE EQU 0X0E ; IOCE/WDTCON: WDT Control Register
_WDTE == 7 ; Control bit is used to enable Watchdog timer
; "0" : Disable WDT
; "1" : Enable WDT
_EIS == 6 ; Control bit is used to difine the function of P60(/INT)pin
; "0" : P60,biderectional I/O pin
; "1" : /INT,external interrupt pin
; Bits 5~0 not used
IOCF EQU 0X0F ; IOCF/IMR: Interrupt Mask Register
; Bits 7~3 not used
mEXIE == 0x04 ; External interrupt enable bit (P60)
; "0" : Disable
; "1" : Enable
mICIE == 0x02 ; Port6 input status change interrupt enable bit
; "0" : Disable
; "1" : Enable
mTCIE == 0x01 ; TCC overflow interrupt enable bit
; "0" : Disable
; "1" : Enable
;io define---------------------------------------
;port5
_BELL1_CH == 0
_BELL1_MUSIC == 1
_BELL2_CH == 2
_BELL2_MUSIC == 3
;PORT6-------------------------------------------
_DPIN == 7
_HKSIN == 6
;------------------------------------------------
A_BUF EQU 0X10
R3_BUF EQU 0X11
R4_BUF EQU 0X12
FLAG EQU 0X14
ABC EQU 0X15
DEF EQU 0X16
TEMP1 EQU 0X17
TEMP2 EQU 0X18
COUNT EQU 0X19
BELLCOUNT EQU 0X1A
LOOP EQU 0X1B
SEGMENT12 EQU 0X1C
SEGMENT34 EQU 0X1D
LOOPANDRFLED EQU 0X1E
HL EQU 0X1F
;------------------------------------------------
B0 == 0x00
B1 == 0x01
B2 == 0x02
B3 == 0x03
B4 == 0x04
B5 == 0x05
B6 == 0x06
B7 == 0x07
;
mB0 == 0x01
mB1 == 0x02
mB2 == 0x04
mB3 == 0x08
mB4 == 0x10
mB5 == 0x20
mB6 == 0x40
mB7 == 0x80
;------------------------------------------------------
INIT_10MS == 0X63 ; 0X63 TIMING 10MS,1/(4mhz/2)*128*(255-99)=10000us
;------------------------------------------------------------------
ORG 0
ADD A, @0FFH
JMP START
;------------------------------------------------------
ORG 0X08
DISI
RETI
;---------
MOV A_BUF, A
SWAP A_BUF
SWAPA R3
MOV R3_BUF, A
MOV A, FSR
MOV R4_BUF, A
JBC RF, _TCIF
JMP INT_TCC
JBC RF, _ICIF
JMP INT_PORT6
JBC RF, _EXIF
JMP INT_EXT
INT_END:
MOV A, R4_BUF
MOV FSR, A
SWAPA R3_BUF
MOV R3, A
SWAPA A_BUF
RETI
;------------------
INT_TCC:
MOV A, RF
AND A, @0XFE
MOV RF, A
NOP
JMP INT_END
;----------------
INT_PORT6:
MOV A, RF
AND A, @0XFD
MOV RF, A
NOP
JMP INT_END
;-----------------
INT_EXT:
MOV A, RF
AND A, @0XFB
MOV RF, A
NOP
JMP INT_END
;-----------------------------------------------------
; 4MZ CLOCK
;-----------------------------------------------------
DELAY100MS:
MOV A, @1
MOV ABC, A
JMP DELAY1SLOOP
DELAY500MS:
MOV A, @5
MOV ABC, A
JMP DELAY1SLOOP
DELAY1S:
MOV A, @10
MOV ABC, A
DELAY1SLOOP:
MOV A, @100 ;100MS
MOV DEF, A
DELAY100MSLOOP:
CALL DELAY1MS
DJZ DEF
JMP DELAY100MSLOOP
DJZ ABC
JMP DELAY1SLOOP
RET
;-----------------------------------------------------
DELAY3MS:
MOV A, @3
JMP DELAY1XMS
DELAY30MS:
MOV A, @30
DELAY1XMS:
MOV ABC, A
CALL DELAY1MS
DJZ ABC
JMP $-2
RET
;-----------------------------------------------------
; 4MZ CLOCK
;-----------------------------------------------------
DELAY1MS:
MOV A, @256-100 ;1MS
DELAYLOOP:
WDTC
NOP
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
ADD A, @1
JBS R3, _C
JMP DELAYLOOP
RET
;------------------------------------------------------
DELAY160US:
MOV A, @16 ;320US
JMP DELAY10US
DELAY290US:
MOV A, @29 ;575US
JMP DELAY10US
DELAY450US:
MOV A, @45 ;900US
JMP DELAY10US
DELAY550US:
MOV A, @55 ;1100US
JMP DELAY10US
DELAY690US:
MOV A, @69 ;1380US
JMP DELAY10US
DELAY700US:
MOV A, @70 ;1400US
JMP DELAY10US
DELAY730US:
MOV A, @73 ;1.460MS
JMP DELAY10US
DELAY800US:
MOV A, @80 ;800US
JMP DELAY10US
DELAY920US:
MOV A, @92 ;1.84MS
JMP DELAY10US
DELAY1120US:
MOV A, @112 ;2250US
JMP DELAY10US
DELAY1200US:
MOV A, @120 ;1200US
; JMP DELAY10US
DELAY10US:
MOV ABC, A
DELAY10USLOOP:
WDTC
JMP $+1 ;1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1
JMP $+1 ;8
DJZ ABC
JMP DELAY10USLOOP
RET
;--------------------------------------------------
; __7__
; | |
; 2 | | 6
; |__1__ |
; | |
; 3 | | 5
; |__4__ |. 0
;
;--------------------------------------------------
TEL_TAB1:
; TBL
; RETL 0FCH ;0
; RETL 060H ;1
; RETL 0XDA ;2
; RETL 0F2H ;3
; RETL 66H ;4
; RETL 0XB6 ;5
; RETL 0XBE ;6
; RETL 0E0H ;7
; RETL 0FEH ;8
; RETL 0F6H ;9
; RETL 18H ;*
; RETL 30H ;#
; RETL 0CEH ;P
; RETL 8EH ;F
; RETL 02H ;-
; RETL 00H ;NULL
;--------------------------------------------------
; __1__
; | |
; 6 | | 2
; |__7__ |
; | |
; 5 | | 3
; |__4__ |. 8
;
;--------------------------------------------------
;TEL_TAB2:
; TBL
; RETL 3FH ;0
; RETL 06H ;1
; RETL 5BH ;2
; RETL 4FH ;3
; RETL 66H ;4
; RETL 6DH ;5
; RETL 0XD7 ;6
; RETL 07H ;7
; RETL 7FH ;8
; RETL 6FH ;9
; RETL 18H ;*
; RETL 0CH ;#
; RETL 73H ;P
; RETL 71H ;F
; RETL 40H ;-
; RETL 00H ;
;-------------------------------------------------------
SERIALDSP:
BC PORT6, _CLOCK
BS PORT6, _STROBE
MOV A, @16
MOV TEMP1, A
MOV A, ABC
MOV HL, A
SERIALSEND20:
RRC HL
JBS R3, _C
JMP SERIALSEND22
BS PORT6, _DATA
JMP SERIALSEND23
SERIALSEND22:
BC PORT6, _DATA
SERIALSEND23:
NOP
NOP
BS PORT6, _CLOCK
NOP
NOP
NOP
BC PORT6, _CLOCK
DJZ TEMP1
JMP SERIALSEND24
; BC PORT6, _STROBE
BC PORT6, _CLOCK
RET
SERIALSEND24:
MOV A, TEMP1
XOR A, @8
JBS R3, _Z
JMP SERIALSEND20
MOV A, DEF
MOV HL, A
JMP SERIALSEND20
;------------------------------------------------------
START:
WDTC
MOV A, @0X00 ;0X00,P50~P53 OUPUT
IOW IOC5
MOV A, @0
MOV PORT5, A
MOV A, @0X3D ;0X80
IOW IOC6
MOV A, @0
MOV PORT6, A
CLR RF
MOV A, @0XFF ;dont't pull down,p50~p52,p60~p62,0,enable
IOW IOCB
; MOV A, @0XFF ;port6 open_drain,0=enbale
MOV A, @0
IOW IOCC
MOV A, @0XFF ;PORT6 PULL HIGH,0=ENABLE
IOW IOCD
; MOV A, @0X80 ;wdt enable, p60 is geranl purpose i/o pin,not ext int
MOV A, @0
IOW IOCE
WDTC
CLRA
IOW IOCF
MOV A,@0X06
CONTW ;tcc,1:128
CLR 0X01
WDTC
; MOV A,@0X0E
; CONTW
CLR FLAG
CLR ABC
CLR DEF
CLR TEMP1
CLR TEMP2
CLR COUNT
CLR BELLCOUNT
CLR LOOP
MOV A, @12H
MOV SEGMENT12, A
MOV A, @34H
MOV SEGMENT34, A
MOV A, @80H
MOV LOOPANDRFLED, A
;----------------
MAIN:
WDTC
NOP
NOP
CALL DELAY1MS
CALL DELAY1MS
CALL DELAY1MS
CALL DELAY1MS
MOV A, LOOPANDRFLED
AND A, @0FH
MOV ABC, A
JBC LOOPANDRFLED,7
MOV A, @40H
JBC LOOPANDRFLED,6
MOV A, @20H
JBC LOOPANDRFLED,5
MOV A, @10H
JBC LOOPANDRFLED,4
MOV A, @80H
OR A, ABC
; MOV A, @80H
MOV LOOPANDRFLED, A
MOV A, SEGMENT12
JBC LOOPANDRFLED,7
JMP SCREEN3
MOV A, SEGMENT34
JBC LOOPANDRFLED,5
JMP SCREEN3
MOV A, SEGMENT12
JBS LOOPANDRFLED,6
MOV A, SEGMENT34
SCREEN2:
MOV ABC,A
JMP SCREEN4
SCREEN3:
MOV ABC,A
SWAP ABC
SCREEN4:
; MOV A, ABC
; AND A, @0FH
; CALL TEL_TAB1
; AND A, @0FEH
; MOV A, @0XDA
; MOV A, @0FEH
; MOV A, @0FEH
MOV A, @0F6H
MOV ABC, A
; MOV A, LOOPANDRFLED
; MOV A, @0FEH
MOV A, @0FCH
MOV DEF, A
CALL SERIALDSP
JMP MAIN
;-------------------------------------------------------
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -