> Hi, all.
>
> I am having trouble addressing my i2c slave with
> my 16f877's MSSP module, using code from Appendix
> C in "Serial PIC'n". When using my bit-banging
> code, things work fine. I use the same i2c pins,
> but have much better timing WRT setup and hold times.
> Has anybody had problems with the MSSP and needed
> to massage things? I'm trying to communicate between
> two 887s through about 10 feet of CAT5, with i2c lines
> twisted with power and ground. The bitrate is faster
> with the bit-banging, BTW. Here's the MSSP code from
> Serial PIC'n:
>
> send bcf PIR1, SSPIF ;make sure flag is clear
> banksel SSPCON2 ;select bank 1
> bsf SSPCON2, SEN ;initiate START
> banksel PIR1 ;select bank 0
> send2 btfss PIR1, SSPIF ;START completed? if yes, skip next
> goto send2 ;no, go try again
> bcf PIR1, SSPIF ;yes, clear completed flag
> movlw eeslv ;get slave address
> movwf temp ;tag it as write
> bcf temp, 0
> movf temp, w
> movwf SSPBUF ;initiate send slave address
> send3 btfss PIR1, SSPIF ;send completed? if yes, skip next
> goto send3 ;no, go try again
> bcf PIR1, SSPIF ;clear completed flag
> banksel SSPCON2 ;select bank 1
> btfsc SSPCON2, ACKSTAT ;ACK received from slave? if yes, skip
> goto send5 ;no, go terminate transaction
> banksel SSPBUF ;yes, select bank 0
> movf data0, w ;fetch data to send
> movwf SSPBUF ;initiate send data
> send4 btfss PIR1, SSPIF ;send completed? if yes, skip next
> goto send4 ;no, go try again
> bcf PIR1, SSPIF ;yes, clear completed flag
> banksel SSPCON2 ;select bank 1
> send5 bsf SSPCON2, PEN ;initiate STOP
> banksel PIR1 ;select bank 0
> send6 btfss PIR1, SSPIF ;STOP completed? if yes, skip
> goto send6 ;no, go try again
> bcf PIR1, SSPIF ;yes, clear completed flag
>
> Sorry about my crappy email client. Anyway, the
> slave never gets an interrupt from this code. The
> o-scope shows the same timing pattern as my successful
> bit-banging code, but the trailing edges of the MSSP's SCK
> line are close to the SDA transitions. Don't think
> that makes a difference, but...
>
> Thanks for any help,
> Ross
>
>
> __________________________________________________
> FREE voicemail, email, and fax...all in one place.
> Sign Up Now!
http://www.onebox.com
>
> --
>
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> email
spamBeGonelistservspamBeGone
mitvma.mit.edu with SET PICList DIGEST in the body
>
>