This is a multi-part message in MIME format. ------=_NextPart_000_00E1_01C45B0C.919961A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I think I've got the basics of the MSSP module licked. Can someone critique this code and results please. 9th clock pulses are marked, $55 is sent out, $55 comes back so I'm reasonably confident TIA ============================================ i2c mov b'00101000',sspcon1 ; 1 SSPEN ; 1000 master mov b'10000000',sspstat ; 1 slew rate off mov 0x61,sspadd ;I2C baud rate, 100kHz @ 39.3216MHz ;write/read $55 bsf startb ;start bit btfsc startb bra $-2 mov 0xa0,sspbuf ;slave address, write mode btfsc sspstat,r_w bra $-2 mov 0x01,sspbuf ;word address MSB btfsc sspstat,r_w bra $-2 mov 0x23,sspbuf ;word address LSB btfsc sspstat,r_w bra $-2 bcf pir1,sspif mov 0x55,sspbuf ;send data btfsc pir1,sspstat,r_w bra $-2 bcf pir1,sspif ;wait for ACK btfss pir1,sspif bra $-2 bsf stopb ;stop bit btfsc stopb bra $-2 call ms05 ;5ms write cycle delay ;=============================================== bsf startb ;start bit btfsc startb bra $-2 mov 0xa0,sspbuf ;slave address, write mode btfsc sspstat,r_w bra $-2 mov 0x01,sspbuf ;word address MSB btfsc sspstat,r_w bra $-2 bcf pir1,sspif mov 0x23,sspbuf ;word address LSB btfsc sspstat,bf bra $-2 btfss pir1,sspif ;wait for ACK bra $-2 bsf stopb ;stop bit btfsc stopb bra $-2 bsf startb ;start bit btfsc startb bra $-2 mov 0xa1,sspbuf ;slave address, read mode btfsc sspstat,r_w bra $-2 bsf sspcon2,rcen ;enable reception btfss sspstat,bf bra $-2 bcf pir1,sspif bsf sspcon2,ackdt ;send NACK bsf sspcon2,acken btfss pir1,sspif bra $-2 bcf pir1,sspif bsf stopb ;stop bit btfsc stopb bra $-2 btfss pir1,sspif ;wait for ACK bra $-2 movfw sspbuf ;store received byte movwf dg1 ============================================== Research is what I'm doing when I don't know what I'm doing - Wernher von Braun -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads ------=_NextPart_000_00E1_01C45B0C.919961A0 Content-Type: image/gif; name="w-r_i2c.gif" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="w-r_i2c.gif" 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