//----- SETUP SSP AS I2C -----
//I2C requirements:- 100kHz clock high time 4.0uS, clock low time 4.7uS, 400kHz clock high time 0.6uS, clock low time 1.3uS
//The PIC18 does not fully conform to the 400kHz I2C spec (which applies to all rates >100kHz) but may be used with care
//where higher rates are required.
//Lower 7 bits of SSPADD are the baud rate.  ((Tcycle / 2) * SSPADD * 2) = time per bit.  1 / time per bit = frequency.
//400kHz @ 40MHz OSC = SSPADD 25
//100kHz @ 40MHz OSC = SSPADD 100
//100kHz @ 32MHz OSC = SSPADD 80
//100kHz @ 4MHz OSC = SSPADD 10
SSPADD = 100; //setup i2c clk speed
OpenI2C(MASTER, SLEW_OFF); //Slew rate control should be on for 400KHz, off for 100KHz & 1MHz
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *