Jump to content

Recommended Posts

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?



Link to post
Share on other sites



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

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...