Error: extra tokens on end of line


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Vassar, Michigan USA
    Posts
    9

    Default Error: extra tokens on end of line

    After accidentally toggling the breakpoint feature or clicking something in Microcode studio, all of a sudden I get random error messages when compiling. Most of them are:

    [201] ')' expected
    [212] extra tokens on end of line
    [300] too many errors

    If I just start remming out lines, at some point, it will assemble properly. If I rem out one line and then un-rem another suspect line, it still complies OK. I've written other apps with IF...THENs this deep and had no problem. The code on most of the lines are identical except for the values.

    This one really has me stumpped. About 6 months ago, I patched to MicroCode Studio 2.3.0.0 and the compiler is PICBASIC PRO 2.47. This is for 16F877A.

    Is there a setting in MicroCode Studio that could have been changed that is causing this?

    At one point I had this code working fine and then I added one IF-THEN to add a feature and then it wouldn't compile. I took the code out so it would be back to original and it still wouldn't compile.

    I would appeciate any ideas as to what could cause this...

    Here is the code...

    CCP1CON = 0
    CCP2CON = 0

    adcon1 = 6

    trise = 7
    trisc = 191

    porte = 0

    trisa = 255
    trisb = 0
    trisd = 255

    portEval var byte
    portCval var byte
    portCfinval var byte
    stripBit var bit
    portDval var byte
    portAval var byte
    IdNumber var byte
    OutVal var byte

    DEFIne HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    define HSER_SPBRG 25

    BtVar var byte


    portb = 0

    START:

    stripbit = portc.0 'this strips off the first 6 bits of port C
    portcfinval.0 = stripbit 'to use as inputs, while ignoring the RX and TX pins.
    stripbit = portc.1
    portcfinval.1 = stripbit
    stripbit = portc.2
    portcfinval.2 = stripbit
    stripbit = portc.3
    portcfinval.3 = stripbit
    stripbit = portc.4
    portcfinval.4 = stripbit
    stripbit = portc.5
    portcfinval.5 = stripbit

    if porta <> portaval then
    portaval = porta
    hserout [#porte,"A",#porta,13,10] 'the code that the PC recieves has the ID code,
    endif 'the port letter and port value

    if portd <> portdval then
    portdval = portd
    hserout [#porte,"D",#portd,13,10]
    endif


    if (portcfinval <> portcval) then
    portcval = portcfinval
    hserout [#porte, "C", #portcfinval, 13,10]
    endif

    hserin ,100,start,[Idnumber]

    porteval = porte 'here is the code that I added
    if idnumber = porteval then 'port E is the ID code or the chip
    HSERIn ,500,START,[Btvar] ' the chip only responds to serial
    else 'commands that match the ID code
    goto start 'this lets more than one chip operate in parrallel on
    'one serial port
    endif '

    if btvar = 48 then
    HSERIn ,1000,START,[btvar]
    if btvar = 48 then outval.bit0 = 0 'turn on/off bit on port b with serial command from
    if btvar = 49 then outval.bit0 = 1 'PC
    portb = outval
    goto start
    endif
    if btvar = 49 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit1 = 0
    if btvar = 49 then outval.bit1 = 1
    portb = outval
    goto start
    endif
    if btvar = 50 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then Outval.bit2 = 0
    if btvar = 49 then outval.bit2 = 1
    portb = outval
    goto start
    endif
    if btvar = 51 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit3 = 0
    if btvar = 49 then outval.bit3 = 1
    portb = outval
    goto start
    endif
    if btvar = 52 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit4 = 0
    if btvar = 49 then outval.bit4 = 1
    portb = outval
    goto start
    endif

    if btvar = 53 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit5 = 0
    if btvar = 49 then outval.bit5 = 1
    portb = outval
    goto start
    endif

    if btvar = 54 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit6 = 0
    if btvar = 49 then outval.bit6 = 1
    portb = outval
    goto start
    endif
    if btvar = 55 then
    HSERIn ,1000,START,[Btvar]
    if btvar = 48 then outval.bit7 = 0
    if btvar = 49 then outval.bit7 = 1
    portb = outval
    goto start
    endif


    goto start

  2. #2
    Join Date
    Jan 2008
    Location
    Vassar, Michigan USA
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Head banging is over

    I figured it out on my own, just moments after sending out the post, naturally... I went into View, Compile and Program Options, Assembler tab and turned on "Use PMASM". I then compiled the program which it did with ZERO errors. Then I switched it back, turning "Use PMASM" off. Then I compiled it again and it said: "Success 882 Words Used."

    Whatever that was about, I'm glad it is now working.

    UPDATE: I changed a couple lines of code and the errors returned. I switched back and forth between using PMASM and not and the problem went away again. Does anyone have any idea what could be causing this? When the problem doesn't show up, it compiles and I can flash the chip and it works properly. Is there any advantage to just leaving it on "Use PMASM"? Is this a proble with the particular version of MicroCode Studio I'm using?
    Last edited by Jasonce65; - 21st January 2008 at 22:19. Reason: Update

  3. #3
    Join Date
    Jan 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Hello Jason, I'm not too sure about the Microcode problem, (I use PBP 2.44/MPLAB IDE), but there are problems with the code. For instance, unless you've left out some code, the first thing that leaps out:-

    if porta <> portaval then

    You haven't initialised "portaval" with a value to compare to PORTA, so it will ALWAYS contain zero. If that is your intent, use:-

    if PORTA>0 then

    This is better practise. (You can't be sure that "portaval" will contain zero.)

    Also, it's better to put your variable declarations and constant definitions at the beginning of the program, before any executable code. That would make it much easier to read.

    I could go on, but I would suggest that you start with something a little simpler until you have more experience.

    ... Steve.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scarroll01 View Post
    Hello Jason, I'm not too sure about the Microcode problem, (I use PBP 2.44/MPLAB IDE), but there are problems with the code. For instance, unless you've left out some code, the first thing that leaps out:-
    ... Steve.
    You know the upgrade to 2.50a is only $25, solves a lot of problems.

  5. #5
    Join Date
    Jan 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I've never got around to upgrading. I guess I will eventually.
    What problems? (Besides the lack of floating-point support?)

    ... Steve

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scarroll01 View Post
    I've never got around to upgrading. I guess I will eventually.
    What problems? (Besides the lack of floating-point support?)

    ... Steve
    Little stuff that gets on your nerves.
    Check melabs for the list.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I see your code, and I raise you...ok, never mind...
    Seems a bit goofy in my mind, but give this a shot:
    (yes there is a bunch of colons here, only so I can see more of it on the screen)
    Code:
    DEFINE HSER_RCSTA 90h    'ALWAYS capitalize DEFINEs
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_SPBRG 25
    ccp1con = 0 : ccp2con = 0 : adcon1 = 6 : trise = 7 : trisc = 191
    porte = 0 : trisa = 255 : trisb = 0 : trisd = 255 : portEval var byte
    portCval var byte : portCfinval var byte : stripBit var bit
    portDval var byte : portAval var byte : IdNumber var byte
    OutVal var byte : btvar var byte : oldbtvar var byte : portb = 0
    START:
    portcfinval = portc & $3f
    if porta <> portaval then
        portaval = porta : hserout [#porte,"A",#porta,13,10]
    endif
    if portd <> portdval then
        portdval = portd : hserout [#porte,"D",#portd,13,10]
    endif
    if (portcfinval <> portcval) then
        portcval = portcfinval : hserout [#porte, "C", #portcfinval, 13,10]
    endif
    hserin ,100,start,[Idnumber] : porteval = porte
    if idnumber <> porteval then start
    HSERIn ,500,START,[Btvar]
    if ( btvar => 48 ) and ( btvar <= 55 ) then
         oldbtvar = btvar - 48 : HSERIn, 1000 , START , [btvar]
         if btvar <= 49 then outval.0[ oldbtvar ] = btvar.0
         portb = outval : goto start
    endif
    goto start
    Last edited by skimask; - 23rd January 2008 at 17:12.

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  2. RC5 decode on a 10F + Question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th September 2008, 08:20
  3. Replies: 11
    Last Post: - 12th July 2008, 02:36
  4. ELSEIF Block Would be Good.
    By T.Jackson in forum PBP Wish List
    Replies: 30
    Last Post: - 14th May 2007, 03:36
  5. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22

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