Need help with I2C syntax problem?


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Need help with I2C syntax problem?

    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

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Compiles fine here.

    16F690
    PBP 2.46
    DT

  3. #3
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Compile = ok in pbp v2.47

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    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
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Which PIC are you using?

    Whiche IDE?

    Ioannis

  6. #6


    Did you find this post helpful? Yes | No

    Smile

    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...

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  5. I2C eeprom and DS1307 @40MHz problem
    By ius01 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th July 2007, 07:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts