RAM_FIRST == 0X10 ; use EM78P153S
RAM_MAX == 0X2F ; use EM78P153S
TCB_STS == RAM_FIRST
TCB_POINT == TCB_STS + TCB_NUM
TCB_TIM == TCB_POINT + TCB_NUM
TCB_CURRENT == TCB_TIM + TCB_NUM
INT_TEMP == TCB_CURRENT + 1
A_TEMP == INT_TEMP + 1
R3_TEMP == A_TEMP + 1
DP_TEMP == R3_TEMP + 1
LED_1 == 1 ; p51
LED_2 == 2 ; p52
LED_3 == 3 ; p53
LED_4 == 0 ; p60
LED_5 == 1 ; p61
LED_6 == 2 ; p62
LED_7 == 3 ; p63
;====================================================================
; Define special register
;====================================================================
DP_DATA == 0X00
TCC == 0X01
PC == 0X02
R3 == 0X03
DP == 0X04
P5 == 0X05 ; use EM78P153S
P5_CONT == 0X05 ; use EM78P153S
P6 == 0X06 ; use EM78P153S
P6_CONT == 0X06 ; use EM78P153S
PULL_DOWN_CONT == 0X0B ; use EM78P153S / EM78P447S
OPEN_DRAIN_CONT == 0X0C ; use EM78P153S / EM78P447S
PULL_HIGH_CONT == 0X0D ; use EM78P153S / EM78P447S
WDT_CONT == 0X0E ; use EM78P153S / EM78P447S
INT_CONT == 0X0F ; use EM78P153S / EM78P447S
;====================================================================
ORG 0000H
JMP RESET
ORG 0008H
JMP INTERRUPT
;====================================================================
; start program
;====================================================================
ORG 0058H
RESET:
MOV A, @RAM_FIRST
MOV DP, A
INIT_MEMORY:
WDTC
CLR DP_DATA
INC DP
MOV A, DP
AND A, @0X3F
XOR A, @RAM_MAX + 1
JBS R3, Z
JMP INIT_MEMORY
INIT_TIMER:
MOV A, @0B00000111
CONTW
MOV A, @0X80 ; Enable WDT
IOW WDT_CONT
INIT_OTHER:
MOV A, @0B00000000
IOW P5_CONT ; Define p5.0- output,
MOV A, @0B00000000 ; define p6 - output
IOW P6_CONT
MOV A, @0B11111111
MOV P5, A
MOV A, @0B11111111 ; Close LED & motor
MOV P6, A
MOV A, @0B00000000 ; Enable pull down
IOW PULL_DOWN_CONT
MOV A, @0B11111111
IOW PULL_HIGH_CONT ; disable PULL UP
MOV A, @0B11111111
IOW OPEN_DRAIN_CONT ; Disable open drain
MOV A, @0B10101010
MOV P5, A
MOV A, @0B10101010 ; Close LEDs
MOV P6, A
CLR INT_CONT
NOP
MOV A, @0X01
IOW INT_CONT ; enble tcc, diable exter int
;====================================================================
MAIN:
BC P5, LED_1
BC P5, LED_2
BC P5, LED_3
BS P6, LED_4
BS P6, LED_5
BS P6, LED_6
BS P6, LED_7
CALL LED_DELAY_PRO ;这里省略
LED_DISPLAY_02:
BS P5, LED_1
BS P5, LED_2
BS P5, LED_3
BC P6, LED_4
BC P6, LED_5
BC P6, LED_6
BC P6, LED_7
CALL LED_DELAY_PRO ;这里省略
JMP MAIN
;====================================================================
INTERRUPT:
MOV A_TEMP, A
SWAPA R3
MOV R3_TEMP, A
MOV A, DP
MOV DP_TEMP, A
JBC INT_CONT, TCIF
NOP
BC INT_CONT, TCIF
INTERRUPT_RETURN:
MOV A, DP_TEMP
MOV DP, A
SWAPA R3_TEMP
MOV R3, A
SWAP A_TEMP
SWAPA A_TEMP
RETI
;====================================================================
END |