附录一 系统执行软件源程序代码
一、系统多机通信从机源程序代码
Lu Bo
ORG 0000H
SJMP MAIN怎么写代码做软件
ORG 0023H ;串行口中断入口
SJMP SJCS
------------------主程序----------------------------------------------------------------------------------------------------------
MAIN: SLAVE EQU 12
DK EQU
MOV SCON,0B0H
MOV TMOD,20H
MOV TL1,0FDH
MOV TH1,0FDH
MOV IE,90H
SETB TR1
LCALL WDCJ
SETB RS1
CLR RS0
LCALL BCDZH
LCALL DISPLAY
CLR RS1
CLR RS0
SJMP MAIN
------------------串行口中断服务子程序----------------------------------------------------------------------------------
SJCS: CLR RI
PUSH A
PUSH PSW
MOV A,SBUF
XRL A,SLAVE
JZ SJCS0
SJCS1: SETB SM2
POP PSW
POP A
RETI
SJCS0: CLR SM2
MOV SBUF,SLAVE
JNB TI,$
CLR TI
JNB RI,$
CLR RI
MOV A,SBUF
XRL A,11H
JZ SJCS2
SJMP SJCS1
SJCS2: MOV A,25H
ADD A,1
MOV SBUF,A
JNB TI,$
CLR TI
MOV 22H,00H
SJMP SJCS1
----------------18B20温度采集子程序------------------------------------------------------------------------------------
WDCJ: MOV SP,60H
LCALL GET_TEMP
MOV A,21H
MOV C,00H
RRC A
MOV C,01H
RRC A
MOV C,02H
RRC A
MOV C,03H
RRC A
MOV 21H,A
MOV 25H,A
LCALL BCDZH
LCALL DISPLAY
AJMP MAIN
------------------18B20温度采集时序子程序------------------------------------------------------------------------------
GET_TEMP: CLR EA
LCALL INT
MOV A,0CCH
LCALL WRITE
MOV A,44H
LCALL WRITE
LCALL INT
MOV A,0CCH
LCALL WRITE
MOV A,0BEH
LCALL WRITE
LCALL READ
MOV 21H,A
LCALL READ
MOV 20H,A
SETB EA
RET
----------------18B20初始化子程序-----------------------------------------------------------------------------------
INT: CLR EA
L0: CLR DK
MOV R2,200
L1: CLR DK
DJNZ R2,L1
SETB DK
MOV R2,30
L4: DJNZ R2,L4
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论