i2c
Ing. Hynek Sladky
sladky
Středa Březen 17 11:53:02 CET 2004
Dobry den,
tento soft chodi jako I2C slave...
Hynek Sladky
;------ inicializace SLAVE I2C
bsf RP0
movlw 00010000b
movwf sspadd
bsf CKE
bcf RP0
movlw 00110110b
movwf sspcon
;---- I2Ctest
I2C_measure
call WaitI2Caddr
btfsc I2Cstat, 2 ;R/W
goto I2C_measure
call WaitI2Cdata
btfss I2Cstat, 5 ;D/A
goto I2C_measure
...
;======================
WaitI2Caddr
bsf CKP
bcf SSPIF
btfss SSPIF
goto $-1
WaitI2Caddr_1
bsf RP0
movf sspstat, W
bcf RP0
movwf I2Cstat
movf sspbuf, W
btfss I2Cstat, 5 ;D/A
return
btfsc I2Cstat, 2 ;R/W
movwf sspbuf
goto WaitI2Caddr
WaitI2Cdata
bcf SSPIF
btfss SSPIF
goto $-1
bsf RP0
movf sspstat, W
bcf RP0
movwf I2Cstat
movf sspbuf, W
btfsc I2Cstat, 2 ;R/W
movwf sspbuf
bsf CKP
return
PutI2Cdata
movwf sspbuf
bsf CKP
bcf SSPIF
btfss SSPIF
goto $-1
bsf RP0
movf sspstat, W
bcf RP0
movwf I2Cstat
return
;----------------------
Další informace o konferenci Hw-list