工业控制 | 能源技术 | 汽车电子 | 通信网络 | 安防监控 | 智能电网 | 移动手持 | 无线技术 | 家用电器 | 数字广播 | 消费电子 | 应用软件 | 其他方案

24c02的简单操作(汇编)

作者:dolphin时间:2011-05-05

; 24c02的简单操作
scl_2402 bit p3.5
sda_2402 bit p3.7
sp_begain equ 60h
org 0
mov sp,#sp_begain
acall delay
acall delay
acall delay
mov 30h,#0
mov 31h,#1
mov 32h,#2
mov 33h,#3
mov 34h,#4
mov 35h,#5
mov 36h,#6
mov 37h,#7
write: clr a ;address
mov r0,#30h ;point
mov r1,#8 ;sum
acall wrs_2402
cjne r1,#0ffh,next0
sjmp err_2402
next0: acall delay
read: clr a ;address
mov r0,#38h ;point
mov r1,#8 ;sum
acall rds_2402
cjne r1,#0ffh,next1
sjmp err_2402
next1: acall delay
write0: mov a,#8 ;address
mov r0,#38h ;point
mov r1,#8 ;sum
acall wrs_2402
cjne r1,#0ffh,next2
sjmp err_2402
next2: acall delay
sjmp $
err_2402:sjmp $

delay: mov r6,#20 ;24M--5ms----24c02的写入时间间隔
delay_0:djnz r7,$
djnz r6,delay_0
ret
;---------------------------------------------
wI2c equ 0a0h ;器件地址及写操作
rI2c equ 0a1h ;器件地址及读操作
sta_2402: ;启始
setb sda_2402
setb scl_2402
sjmp $+2 ;24M至少间隔周期
sjmp $+2
clr sda_2402
sjmp $+2
sjmp $+2
clr scl_2402
sjmp $+2
sjmp $+2
ret
stp_2402: ;结束
clr sda_2402
setb scl_2402
sjmp $+2
sjmp $+2
setb sda_2402
sjmp $+2
sjmp $+2


关键词: 24c02 简单 操作 汇编

评论

技术专区