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 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 ---