Keni 0 Report post Posted July 6, 2009 Hi, does anyone have any good examples of master and slave code for a 16F88? I have found a few implementations, but nothing that really works. I have read that SourceBoost provides libraries for the master control, has anyone used these? Thanks Quote Share this post Link to post Share on other sites
Tim Zim 0 Report post Posted July 6, 2009 Keni I used the i2c_test example code in C:\Program Files\SourceBoost\Samples\C\BoostC Set the i2c software args etc. for the 18F88 as: //////////////////////////////////////////////////////////////////////////// // i2c software implementation template arguments //////////////////////////////////////////////////////////////////////////// // SCL = PORTB.3 // SDA = PORTB.4 #define i2c_ARGS 3, PORTB, TRISB, 4, PORTB, TRISB, e_SSPCON1, e_SSPCON2, \ e_SSPSTAT, e_SSPBUF, e_SSPIF_BIT, e_SSPIF_PIR, \ e_BCLIF_BIT, e_BCLIF_PIR, 7, e_SSPADD, (i2c_reset_wdt | i2c_SMP) // RAM used by the software i2c driver to emulate the equivalent i2c hardware registers unsigned short swi2c_SSPCON1@0x40; // define location for the emulated SSPCON1 unsigned short swi2c_SSPCON2@0x41; // define location for the emulated SSPCON2 unsigned short swi2c_SSPSTAT@0x42; // define location for the emulated SSPSTAT unsigned short swi2c_SSPBUF@0x43; // define location for the emulated SSPBUF unsigned short swi2c_SSPIF_PIR@0x44;// define location for the emulated SSPIF_PIR unsigned short swi2c_BCLIF_PIR@0x45;// define location for the emulated BCLIF_PIR unsigned short swi2c_SSPADD@0x46; // define location for the emulated SSPADD This worked perfectly. Truth is I didn't use the hardware setting as I did not understand the I2C_divisor setting (do now), or what the addresses of the various registers should be (also do now, though for a PIC18F2550). I hope this helps. Quote Share this post Link to post Share on other sites