master and slave communication error in read operation

Status
Not open for further replies.

hodahussein

Full Member level 2
Joined
Apr 17, 2007
Messages
144
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,276
dear all

i prepared the software one for master side and one for slave side. depending on microchip technology pic16f877.
- master want to read data from slave so, i had written the following steps in master side to read from slave
1-start condition
2-send address(ex:0x03)
3-Test ACk
4-read data
5-stop condition
and for slave side. i read the SSPSTAT register in order to determine which the operation read or write
so i check if slave received [B'10001100'] or not . if yes so this mean that the matched address and master need to read data from slave

so the waveform of I2C between master and slave : i see it on oscliscope the start condition ok and address is ok and ack is ok but after this occurs the SDA and SCL are active low.
but in slave side i am sure from set CKP bit in SSPCON reg to release the clock.
and if i repeat this operation again [master read steps ] the master side wait SSPIF to be set

------------------
Start Condition
BSF STATUS,RP0
bsf SSPCON2,SEN
BCF STATUS,RP0
CALL Wint
return
-----------------
Wint
NOP
BCF PIR1,SSPIF
clrwdt
btfss PIR1,SSPIF ; Check if I2C operation done
goto $-2 ; I2C module is not ready yet
return
;-------------------------
StopCondition
BSF STATUS,RP0
bsf SSPCON2,PEN
BCF STATUS,RP0
CALL Wint
return
------------------------
Send_Addr
movwf SSPBUF
CALL Wint
return


why this communication did not work well ?
is there something i missed it

wait your helps
regards
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…