At 15:36 12.02.1998 -0800, you wrote: >I agree. some boilerplate for i2c slave would be helpful, if anyone has >any. OK, what do you think about this one: ;*************************************************************************** ;*********** ISR: Interrupt Service Routine MAIN *************************** ;*************************************************************************** ISR clrwdt bcf INTCON,GIE ; disable all interrupts PUSH btfsc PIR1,SSPIF ; call I2C ; I2C-Service POP bsf INTCON,GIE ; enable all interrupts retfie ;*************************************************************************** ; I2C: ISR-I2C-Unit ;*************************************************************************** I2C bcf PIR1,SSPIF ; Clear SSP Interrupt bsf STATUS,RP0 ; switch to Bank1 btfss SSPSTAT,DA_ ; If Address were received last goto access ; decode next access btfsc PS,I2C_RW ; Data were received goto rd_dat ; master has read data goto wr_dat ; master wrote data access btfsc SSPSTAT,RW_ ; goto rd_adr ; master read access will follow goto wr_adr ; master write access will follow rd_dat bcf STATUS,RP0 ; switch to Bank0 movf TXCHECK,W ; load Checksum movwf SSPBUF ; in I2C-Register bsf SSPCON,CKP ; enable serial clock return ; data was read by master wr_dat bcf STATUS,RP0 ; switch to Bank0 movf SSPBUF,W ; Get I2C data movwf RXBUF ; store it in RXBUF goto sort_rx ; result in RXBUF will be sorted rd_adr bsf PS,I2C_RW ; copy RW_-Bit to PS bcf STATUS,RP0 ; switch to Bank0 movf TXDATA,W ; load DATA movwf SSPBUF ; in I2C-Register bsf SSPCON,CKP ; enable serial clock return ; data will be read by master wr_adr bcf PS,I2C_RW ; copy RW_-Bit to PS bcf STATUS,RP0 ; switch to Bank0 movf SSPBUF,W ; read SSPBUF in order to clear BF return ; data will be written by master ;*************************************************************************** ; INIT: Init Peripheral Functions and Ports ;*************************************************************************** bsf STATUS,RP0 ; switch to Bank1 bsf PIE1,3 ; enable I2C interrupt movlw 0x42 ; I2C slave address set to $42 movwf SSPAD ; bcf STATUS,RP0 ; switch to Bank0 movlw B'00110110' ; I2C 7Bit slave mode movwf SSPCON ; movlw B'11000000' ; enable peripheral movwf INTCON ; and global interrrupt Actually it's for a 3 byte transmission, consisting of command, data and checksum. But it should be easy to adapt it to any purpose. So long Thomas =8-) ********************************************************** * Thomas Magin FON: ++49-761-4543-489 * * marquette-Hellige GmbH FAX: -507 * * Emergency Systems email: magin@hellige.de * * Munzinger Str. 3 * * D-79111 Freiburg / Germany * **********************************************************