ORG 00H
AJMP MAIN
MAIN:
SDA EQU P1.2
SCL EQU P1.7
ACALL STAR
tiIC
MOV A,90H
ACALL WRITE
MOV A,40H
ACALL WRITE
MOV A,0FFH
ACALL WRITE
ACALL STOPIIC
DELAY:
NOP
NOP
NOP
NOP
NOP
RET
STARTIIC:
SETB SCL ; 起始IIC后两条数据线均为低电平
SETB SDA
ACALL DELAY
CLR SDA
ACALL DELAY
CLR SCL
RET
STOPIIC:
CLR SDA;终止IIC后,时钟为高电平,数据为低电平
SETB SCL
ACALL DELAY
SETB SDA
ACALL DELAY
CLR SDA
RET
WRITE:
MOV R7,#8;用来判断发送是否完成
W1: RLC A
MOV SDA,C
SETB SCL
ACALL DELAY
CLR SCL
DEC R7
DJNZ R7,W1
SETB SDA
SETB SCL
ACALL DELAY
MOV C,SDA
CLR SCL
JC WRITE
RET
END
一周热门 更多>