PDA

View Full Version : What is wrong with this Ic2 code?



Mad_Labs
- 23rd September 2005, 22:19
Hi,

I just can't seem to get this to work. I am using a MAX6953 with a PIC16F88. I have read Melanie's post about the IC2 command, and still can't get it going. I can communicate with the device using a Stamp, but not a PIC. The device ID is set to $A2. I never get to the failed routine, no matter what device ID I use, but if I reverse the SDA and SCL pins I do. The serouts go to a serial LCD, definitions etc, not in code.

Here is the code:

@ DEVICE INTRC_OSC,MCLR_ON,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 8
OSCCON = $70

char var byte
sda var portb.0
scl var portb.1
addr var word
ic2dev var byte
addr = $04
ic2dev = $A2

i2cwrite sda,scl,ic2dev,addr,[%00000010], failed
pause 10
i2cread sda,scl,ic2dev,addr,[char]
serout2 portb.3,16468,[bin8 char]
END

failed:
serout2 portb.3,16468,["No Worky"]
END

Any ideas? I'm running out of hair to pull and my forehead/keyboard are bloody ;-0

Jonathan