At 23:56 11.02.1998 -0500, you wrote: > I've checked the archive and found a few good pointers on using the SSP in >I2C slave mode but I haven't found any example or boiler plate code. Anyone >have a pointer? Reinventing and debugging the wheel not my idea of fun. BTW >if anyone would like ANSI std CRC-16 code for 12c5xx and 16cxx, I've got a >nice fast table driven implementation. Hi, have a look at the attachment. It's written for a 3-byte access (command, data, checksum) but it should be easy to adapt it for your purpose. Regards Thomas =8-) ;*************************************************************************** ;*********** 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 ********************************************************** * 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 * **********************************************************