"I don't see you initialising this chip. Last I checked it had twelve registers... let's set them up the way you'd like to see them.... then and only then you can perform I/O."
The default values for all the registers seem to be what I want except for the IODIR register pair. According to the datasheet, we are able to write to both registers in a single write operation. The 1st I2CWRITE is supposed to write all ZEROES to both registers (IODIR0 and IODIR1):
I2CCTRL = %01000000
I2CLOC = $06 ' Set location to IODIR register pair
I2CBYTE1 = %00000000 ' Set pins 0-7 as output
I2CBYTE2 = %00000000 ' Set pins 8-15 as output
I2CWRITE I2CSDA,I2CSCL,I2CCTRL,I2CLOC,[I2CBYTE1,I2CBYTE2],ERRORIO
----------------------------------------------------------------------
"Have you remembered to GROUND A2, A1 and A0 to match your IOCCTRL Byte?"
Yup.
----------------------------------------------------------------------
"Have you remembered to leave TP floating?"
Yup.
----------------------------------------------------------------------
"Have you remembered to GROUND all THREE Vss pins?"
Yup.
----------------------------------------------------------------------
"Have you remembered Rext and Cext for your external Clock, or alternatively cross-connected it to Fosc of your PIC?"
Yup, on the RC connection. I wanted to try your 2nd suggestion, but I can't see an Fosc pin on the 16F877.
----------------------------------------------------------------------
I've even connected all 16 I/O pins to LEDs, so I can easily see what is happening.
Robert
![]()
Bookmarks