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单片机