PIC16F877单片机硬件IIC编程实例
BANKSEL I2C_Addr ; The "BANKSEL" may not necessary if I2C_Addr is @ the same bank with SSPBUF
movf I2C_Addr,W ; The Address you wish to "READ" from
BANKSEL SSPBUF
movwf SSPBUF
call WaiTI2C
call RstarTI2C ; Restart CondiTIon !!
call WaiTI2C ; Wait Until Restart OK !!
BANKSEL SSPBUF
movlw B'10100001' ; Write Read Command
movwf SSPBUF
call WaitI2C
call RecI2C ; Enable I2C Receive
call WaitI2C ; Wait Until Buffer Received
BANKSEL SSPBUF
movf SSPBUF,W ; Save to I2C_Data First !!
下载地址
用户评论