您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机PIC的I2C读写程序 正文
PIC的I2C读写程序

PIC的I2C读写程序

点击数:7488 次   录入时间:03-04 11:36:41   整理:http://www.55dianzi.com   PIC单片机
CALL    BSTOP           ; Generate STOP bit
MOVF    RXBUF,W         ; Save data from buffer
MOVWF   DATAI           ; to DATAI file.
goto    rd_end
;
;Test program to read and write ramdom
start
movlw   0AE             ;set A2=A1=A0=1
movwf   SLAVE           ;       /
movlw   2               ;set r/w loc. = 2
movwf   ADDR            ;       /
movlw   55              ;write 55 to SEEPROM
movwf   DATAO           ;       /
goto    WRBYTE          ;write a byte
wrt_end
call    delay           ;wait for write
;operation (internal)
goto    RDBYTE          ;read back data
rd_end
movlw   55              ;test if read
xorwf   DATAI,W         ;correct?
btfss   STAT,Z          ;yes then skip
wrong   
goto    wrong
correct
goto    correct
;
;At 2.0Mhz, delay = approx. 3mS.
delay
clrf    1F              ;clear last location
dly1
nop
nop
nop
decfsz  1F, F           ;reduce count
goto    dly1            ;loop
retlw   0
;
org     0x1FF
goto    start
;
END



上一页  [1] [2] [3] [4] [5] 


本文关键字:程序  PIC单片机单片机-工控设备 - PIC单片机