circuitpro
- 15th July 2010, 23:12
I have not used a PIC18F6722 before, but needed two UART PORTS so decided to give it a try. I did not expect to have I2C issues, but when I try to do a read (of a PCF8574) using I2C port 1 it always returns DEC 16. When troubleshooting this, I pulled all the PCF8574's from their sockets, and also removed an EEPROM from the buss. Now the buss is empty except for two pullup 4.7K pullup resistors. It STILL returns DEC 16! I carefully examined the traces on the board, and they are clean and not tied to anything they shouldn't be. I also tried the same code on the second I2C port (which also has nothing on it but pullups) and it has the decency to return 0. To me that means that it's probably some conflict on port C, or other configuration error that I'm not aware of, or possibly a compiler error (2.60 Patch A).
Can anybody spot what I'm doing wrong?
Thanks,
Len
'PIC18F6722
ASM
CLRF PORTC
MOVLW 10000000b ;SET PIN DIRECTION
MOVWF TRISC
CLRF PORTD
MOVLW 00000010b ;SET PIN DIRECTION
MOVWF TRISC
ENDASM
DEFINE OSC 20 'XTAL FREQUENCY
'DEBUG PORT
DEFINE DEBUG_REG PORTD 'DEBUG PINS ARE IN PORTD
DEFINE DEBUG_BIT 0 'TRANSMIT DEBUG PIN IS PORTD.0
DEFINE DEBUG_BAUD 115200 '115200 BAUD
DEFINE DEBUG_MODE 0 'NO INVERSION
DEFINE DEBUGIN_BIT 1 'RECEIVE DEBUG PIN IS PORTD.1
X VAR BYTE
TEST:
I2CREAD PORTC.4,PORTC.3,%01000001,[X] 'DOESN'T WORK - ALWAYS RETURNS DEC 16
'I2CREAD PORTD.5,PORTD.6,%01000001,[X] 'WORKS
DEBUG BIN8 X,10,13
PAUSE 500
GOTO TEST
Can anybody spot what I'm doing wrong?
Thanks,
Len
'PIC18F6722
ASM
CLRF PORTC
MOVLW 10000000b ;SET PIN DIRECTION
MOVWF TRISC
CLRF PORTD
MOVLW 00000010b ;SET PIN DIRECTION
MOVWF TRISC
ENDASM
DEFINE OSC 20 'XTAL FREQUENCY
'DEBUG PORT
DEFINE DEBUG_REG PORTD 'DEBUG PINS ARE IN PORTD
DEFINE DEBUG_BIT 0 'TRANSMIT DEBUG PIN IS PORTD.0
DEFINE DEBUG_BAUD 115200 '115200 BAUD
DEFINE DEBUG_MODE 0 'NO INVERSION
DEFINE DEBUGIN_BIT 1 'RECEIVE DEBUG PIN IS PORTD.1
X VAR BYTE
TEST:
I2CREAD PORTC.4,PORTC.3,%01000001,[X] 'DOESN'T WORK - ALWAYS RETURNS DEC 16
'I2CREAD PORTD.5,PORTD.6,%01000001,[X] 'WORKS
DEBUG BIN8 X,10,13
PAUSE 500
GOTO TEST