EM78P156写的pt2262 源代码
;this program is HOME ALARM
;
n
;this progam write and test for 01.2.18---3.5
;Chip EM78P156 F=3.58 MHz
;SETUP : CYCLE=2,CLOCK=4,ENABLE WDT
;define ram
;**********************************************************
IND == 0
RTC == 1
PC == 2
STATUS == 3
FSR == 4
RA == 5
RB == 6
;define stutas bit
;**********************************************************
C == 0
Z == 2
;define ra bit
;**********************************************************
R0 == 0
R1 == 1
R2 == 2
R3 == 3
;define rb bit
;**********************************************************
SEND == 1
RFIN == 4 REC RF IN
;DEFINE INTR
;**********************************************************
INTR == 0xf
TCIF == 0
ICIF == 1
EXIF == 2
;define cont bit
;**********************************************************
PAB == 3
TE == 4
TS == 5
INT_FLG == 6
;DEFINE PULL_DOWN
;**********************************************************
IOCB == 0xb
;DEFINE OPEN_DRAIN
;**********************************************************
IOCC == 0xc
;DEFINE PULL_HIGH
;**********************************************************
IOCD == 0xd
;define wdt bit
;**********************************************************
IOCE == 0xe
ROC == 4
EIS == 6
WDTE == 7
;DEFINE INT MASK
;**********************************************************
IOCF == 0xf
TCIE == 0
ICIE == 1
EXIE == 2
;define ram
;**********************************************************
FLG1 == 0x10 KEY STATUS
FLG2 == 0x11
TEMP1 == 0x12
TEMP2 == 0x13
TEMP3 == 0x14
TIME == 0x18
BITCNT == 0x19
CODECNT == 0x1f
;
;DEFINE FLG1 SEND IR
;**********************************************************
ENTX == 7
RELEASE == 0
;
;##########################################################
;**********************************************************
ORG 0x0
JMP RESET
NOP
NOP
NOP
NOP
NOP
NOP
ORG 0x10
;#########################################################
D4ms:
MOV A,@0x1f
JMP DLYX
D120us MOV A,@0x1
DLYX:
MOV TEMP1,A
DLY: MOV A,@0xf
MOV TEMP2,A
DLY4 NOP
DJZ TEMP2
JMP DLY4
DJZ TEMP1
JMP DLY
RET
;##########################################################
;*****************PROGAM RESET*****************************
RESET:
MOV A,STATUS
AND A,@0x18 GET TO PD
JBC STATUS,Z
JMP MAIN1
CLR FLG1 CLR ALL FLAG
CLR FLG2
MAIN1:
MOV A,@0xf8 DIABLE PULL_DOWN
IOW IOCB
MOV A,@0x0 DISABLE OPEN_DRAIN
IOW IOCC
MOV A,@0xfe RB0 PULL HIGH,DISABLE PULL_HIGH
IOW IOCD
MOV A,@0x80 ENABLE WDT, INT
IOW IOCE
MOV A,@0x0 ENABLE EX_INT
IOW IOCF
MOV A,@0x0 RA IN
MOV RA,A
MOV A,@0x13
MOV RB,A
CLR INTR
MAIN2:
WDTC
MOV A,@0x0 SELECT SCAL WDT=1:2
CONTW DISABLE INT
NOP
NOP
NOP
MOV A,@0xf
IOW RA
MOV A,@0x11
IOW RB
SEND_RF:
WDTC
BS RB,SEND
BC RB,2
BC RB,3
JBS FLG1,RELEASE
JBS RA,1
JMP SEND_RF_OVER
BS FLG1,RELEASE
MOV A,@0x2
MOV TIME,A
SEND_SYNC:
MOV A,@0x10
MOV BITCNT,A
SEND_ADDR:
BC RB,SEND
CALL D120us
BS RB,SEND
CALL D120us
CALL D120us
CALL D120us
DJZ BITCNT
JMP SEND_ADDR
MOV A,@0x8
MOV BITCNT,A
SEND_DATA:
BC RB,SEND
CALL D120us
CALL D120us
CALL D120us
BS RB,SEND
CALL D120us
DJZ BITCNT
JMP SEND_DATA
BC RB,SEND
CALL D120us
BS RB,SEND
WDTC
CALL D4ms
CALL D120us
CALL D120us
CALL D120us
CALL D120us
DJZ TIME
JMP SEND_SYNC
SEND_RF_OVER:
NOP
BS RB,SEND
JMP MAIN1
上一篇:EM78C156E+1621显示汇编例子
下一篇:EMC8BIT单片机指令应用的误区与技巧
推荐阅读最新更新时间:2024-03-16 15:53