PDA

View Full Version : Need help with I2C syntax problem?



Michael Wakileh
- 18th July 2007, 20:08
Hello everyone. I've been going crazy a few hours now, trying to get my code to compile an i2cwrite command. No matter what I do, whenever the i2cwrite line is in the code I get the following compile errors

67:[226] numeric constant or symbol name expected
67:[201] ')' expected
67:[212] extra tokens on end of line
67:[300] too many errors

Here is a snippet of my code that compiles fine without the i2cwrite line:

Define OSC 4
ansel = 0
anselh = 0
TrisA = 0
TrisB = 0
TrisC = 0
CCP1CON = 0

DEFINE DEBUG_BIT 7 'Set DEBUG pin
DEFINE DEBUG_BAUD 2400 'Set DEBUG baud rate
DEFINE DEBUG_MODE 1 'Set DEBUG mode inverted

'DEFINE I2C_HOLD 1

I2CDataPIN VAR PortB.4 ' I2C data pin
I2CClockPIN VAR PortB.6 ' I2C clock pin

srfdevice VAR BYTE 'FOR SRF02 preprogrammed adress $E0
srfdevice = $E0

srfregister0 VAR byte 'register 0 is the COMMANDregister of the SRF02
srfregister0 = $00

cmcommand VAR byte
cmcommand = 81 '$51 = 81 = Ranging command for results in cm


Main:
i2cwrite I2CDatapin,I2CClockpin,srfdevice,srfregister0,[cmcommand]

'this is where I have my problem

pause 1000
GOTO Main



Please can someone confirm if I have a syntax error. Thanks...

-mike

Darrel Taylor
- 18th July 2007, 20:43
Compiles fine here.

16F690
PBP 2.46

colarsson
- 18th July 2007, 22:40
Compile = ok in pbp v2.47

Archangel
- 19th July 2007, 02:43
Hello Michael,
It compiles ok for me for a 16f884, not so with say 16f877. Is there more code like say config fuse settings which could be throwing you a curve?
I did not read any data sheets to see if 16f877 has I2C, maybe why it does not compile. :) also how old a version of PBP are you using?
JS

Ioannis
- 19th July 2007, 07:26
Which PIC are you using?

Whiche IDE?

Ioannis

Michael Wakileh
- 19th July 2007, 19:11
Thanks for the help guys... For some reason everything's working fine today. Haven't changed a thing...I was programming on a computer that had been brought out of hibernation. Thinking back, I've repeatedly had a few problems I couldn't explain. Perhaps there's a problem with the ram, or maybe it's just time to do a clean installation again...