ErnieM
- 17th May 2006, 18:47
I believe I must be missing something here. My harware is 100% as it is tested with some code from a diffrent compiler and it works just fine.
I load the code from PBP and get garbage.
What I see is what looks like a correct I2C write cycle (even ack is correct), except the clock line does not go high at the end before the data line (illegal stop generated). The clock line then stays low until the next run thru the loop, where the correct data states are generated, but no acks.
Yes, there are pull-ups there. The hardware works with other code.
What could be missing that the PBP compiler needs?
DEFINE OSC 8 ' 8 MHZ CLOCK
asm
__config _CONFIG1, 2f50h ; no clock out
__config _CONFIG2, 3ffch
endasm
d2a_addr CON %00100000
I2C_addr var byte
I2C_data VAR Word
init:
OSCCON = %01110000 ' use internal 20MHz clock
ANSEL = %00000001 ' AN0 only as analog 16F88
loop:
I2C_addr = d2a_addr
I2C_data = $CC80
I2CWRITE PORTA.7, PORTA.6, I2C_addr, I2C_data
pause 5
Goto loop
I load the code from PBP and get garbage.
What I see is what looks like a correct I2C write cycle (even ack is correct), except the clock line does not go high at the end before the data line (illegal stop generated). The clock line then stays low until the next run thru the loop, where the correct data states are generated, but no acks.
Yes, there are pull-ups there. The hardware works with other code.
What could be missing that the PBP compiler needs?
DEFINE OSC 8 ' 8 MHZ CLOCK
asm
__config _CONFIG1, 2f50h ; no clock out
__config _CONFIG2, 3ffch
endasm
d2a_addr CON %00100000
I2C_addr var byte
I2C_data VAR Word
init:
OSCCON = %01110000 ' use internal 20MHz clock
ANSEL = %00000001 ' AN0 only as analog 16F88
loop:
I2C_addr = d2a_addr
I2C_data = $CC80
I2CWRITE PORTA.7, PORTA.6, I2C_addr, I2C_data
pause 5
Goto loop