Try this:
I2C_Slave: ' I2C slave subroutine
IF R_W Then
I2C_Read: ' I2C read data from us ' THIS SECTION IS WORKING!
IF !d_a Then txbufferindex = 0
Repeat
Repeat
Until !bf
wcol = 0:sspbuf = txbuffer[txbufferindex]
Until !wcol
txbufferindex = txbufferindex + 1 ' increment index
IF txbufferindex = txbufferlen Then txbufferindex = 0 ' all bytes have been tx reset index
Else
IF !D_A Then
InByte=SSPBUF 'here is your error ! You don't empty the buffer!!!!!!!!!!!!!!!!!!!!!!
else
I2C_Write: ' I2C write data to us ' THIS SECTION NOT WORKING
If BF Then
InByte = SSPBUF ' Put buffer data into array
if rxbufferindex<rxbufferlen then Rxbuffer[Rxbufferindex] = InByte:rxbufferindex = rxbufferindex + 1
ENDIF
SSPov = 0 ' Clear overflow flag
endif
endif
ckp = 1 ' release clock, allowing read by master (makes no difference (yet))
SSPIF=0
The CODE-code is messy
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks