
Originally Posted by
Lazuli
...
The problem I am having is during compilation which halt on the instruction:
SSPCON2 = 0
...
I have used I2C a lot, mainly on 16F628, 16F877, MCP23016 and external eeproms, and don't recall having to bother with that instruction.
Here are I2C-related instructions from one of my 16F628 programs. It reads from an MCP23016 I/O Expander, but the concept remains the same for all reads.
Code:
...
DEFINE OSC 16
DEFINE I2C_SLOW 1 ' Access I2C device above 8MHz
DEFINE I2C_HOLD 1 ' Permit I2C device to hold clock line low
pinSCL VAR PortA.2
pinSDA VAR PortA.3
varAddressI2C VAR BYTE
varCommandI2C VAR BYTE
varButtonsLeft VAR WORD ' MCP23016 chips have 16 I/O pins
conInLeftAddr CON %01000010 ' MCP23016 at hardware address "010"
conGenPurpRegI2C CON $00
...
Main:
varAddressI2C = conInLeftAddr
varCommandI2C = conGenPurpRegI2C
I2CREAD pinSDA,pinSCL,varAddressI2C,varCommandI2C,[varButtonsLeft]
...
Hope there's something in there that will help you get going.
EDIT: One last thing, I have 4K7 1/4W pull-up resistors on SCL and SDA.
Bookmarks