Searching \ for 'Question on SSPCON in 16F877, I2C Master' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/i2cs.htm?key=i2c
Search entire site for: 'Question on SSPCON in 16F877, I2C Master'.

Truncated match.
PICList Thread
'Question on SSPCON in 16F877, I2C Master'
1999\10\19@151655 by Bob Corkery

flavicon
face
    I am using a 16F873 in master I2C mode to send data only to a Dallas
    digital potentiometer DS1803. I have just started programming it. Here
    is my code, (mostly copied from the on-line conference for SSP from
    Microchip's web site). It is crude, does not use interupts or do any
    extensive error checking, but it is working.

    I set up SSPADD for a 100KHz clock speed with a 4MHz crystal. It works
    at 400KHz but you need lower value pullup resistors on the SDA and SCL
    lines to drive it. Don't forget the pullup resistors, since these
    lines are open collector on I2C devices.

    The DS1803 requires three bytes of info, a control byte to identify
    the correct device which includes its address, a command byte ie.
    write to Pot.#0, and a data byte.


;set up I2C Port
       bsf     STATUS,RP0      ;Bank 1
       movlw   0x60
       movwf   SSPCON2
;       movlw   0x03            ;400KHz @ 4MHz Clock
       movlw   0x0A            ;100KHz @ 4MHz Clock
       movwf   SSPADD
       bcf     STATUS,RP0      ;Bank 0
       clrf    SSPSTAT
       movlw   0x28
       movwf   SSPCON
       bsf     SSPCON,SSPEN


;
; I2C Master Write to Dallas DS1803
;
WriteI2C:
       bcf     STATUS,RP0      ;Bank 0
       bcf     PIR1,SSPIF
       bsf     STATUS,RP0      ;Bank 1
       bsf     SSPCON2,SEN     ;send Start bit
       bcf     STATUS,RP0      ;Bank 0
mw1     btfss   PIR1,SSPIF
       goto    mw1

       movlw   0x50            ;send control byte, identify the correct DS1803
       movwf   SSPBUF
       bcf     PIR1,SSPIF
mw2     btfss   PIR1,SSPIF      ;wait for ACK
       goto    mw2

       movf    Data1,0         ;send command byte; ie Write Pot1
       movwf   SSPBUF
       bcf     PIR1,SSPIF
mw3     btfss   PIR1,SSPIF      ;wait for ACK
       goto    mw3

       movf    Data2,0         ;send data byte
       movwf   SSPBUF
       bcf     PIR1,SSPIF
mw4     btfss   PIR1,SSPIF      ;wait for ACK
       goto    mw4

       bcf     PIR1,SSPIF
       bsf     STATUS,RP0      ;Bank 1
       bsf     SSPCON2,PEN     ;Send Stop bit
       bcf     STATUS,RP0      ;Bank 0
mw5     btfss   PIR1,SSPIF
       goto    mw5
       return

______________________________ Reply Separator _________________________________
Subject: Question on SSPCON in 16F877
Author:  Jim Main <spam_OUTj.mainTakeThisOuTspamNET.NTL.COM> at Internet
Date:    10/19/1999 6:47 PM


I'm trying to get a 16F877 to talk to a 24LC02B -  so far without much
success...

In SSPCON, the bottom 4 bits set up the I2C mode.  I've tried  1000  - where
clock = Fosc/(4*(SSPADD+1)) & couldn't get it to work.

Does anyone know what I2C firmware controlled master mode is (& what speed
it would run at & whether it's clock dependant)

& what does "slave idle" mean in the context of the above.

Has anyone got I2C master mode working on the '877??

Jim
---

1999\10\19@153406 by Jim Main

flavicon
face
This is very helpful - thanks!

Jim

----- Original Message -----
From: Bob Corkery <.....bcorkeryKILLspamspam@spam@VICR.COM>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: 19 October 1999 20:06
Subject: Re: Question on SSPCON in 16F877, I2C Master


>      I am using a 16F873 in master I2C mode to send data only to a Dallas
>      digital potentiometer DS1803. I have just started programming it.
Here
>      is my code, (mostly copied from the on-line conference for SSP from
>      Microchip's web site). It is crude, does not use interupts or do any
>      extensive error checking, but it is working.

1999\10\20@045828 by Jim Main

flavicon
face
Bob,  still not having too much luck..  what values of pullup resistors for
100KHz operation?  I'm using 10K ones at the moment.

Your code:  don't think it makes much difference, but SSPSTAT is in bank 1
not bank0.  The values you loaded into SSPADD aren't correct (if you use the
formula) - but again, don't know if this would make a difference...

Jim

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...