üritan mina siin i2c slave-t oma pic-iga mängida, masterit juba oskan (kuna see kood oli olemas)
kood on selline, kuid sinna com porti saadetakse suva numbrid
et kus ma siin puuse panen?
PIC on 16F627 @ 4MHz
SDA on RB0/INT
SCL on RB4
maki sisselülitamisel tuleb siis selline läbu
kood on selline, kuid sinna com porti saadetakse suva numbrid
et kus ma siin puuse panen?
PIC on 16F627 @ 4MHz
SDA on RB0/INT
SCL on RB4
Kood:
;; SL - Slave
;;Interupt
org 0x04 ;This is where PC points on an interrupt
movwf TEMP ;Store the value of w temporarily
; check start bit, SDA gets low & SDL is high
btfss SL_I2C_PORT, SL_SCL
goto iend ; SDL is low, false interupt
; start bit detected
clrf InputByte
movlw 0x08
movwf _N ; set index to 8
SCL_Low btfsc SL_I2C_PORT, SL_SCL ; wait until SCL gets low
goto SCL_Low
SCL_Hi btfss SL_I2C_PORT, SL_SCL
goto SCL_Hi
; data ready
btfss SL_I2C_PORT, SL_SDA
bcf STATUS, C
btfsc SL_I2C_PORT, SL_SDA
bsf STATUS, C
rlf InputByte, F ; i_byte = i_byte << 1 | 0
decfsz _N, F ; decrement index
goto SCL_Low
movf InputByte, w
call XMIT_RS232
iend
bcf INTCON, 1 ; clear interupt
movf TEMP,w ;Restore w to the value before the interrupt
retfie ;Come out of the interrupt routine
Kood:
000000f0: ff 44 ff ff f8 ff ff a3 e1 fd ff f8 3f ff fe 00 00000100: ff ff f3 ff ff ff ff ff 22 ff ff cf ff ff ff fe 00000110: ff ff e0 7f ff ff ff ff ff 7f ff ff ff ff ff ff 00000120: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00000130: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00000140: ff ff ff ff ff ff ff ff ff ff ff


Comment