Weird compile issue 7 segment LED display


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Unhappy Weird compile issue 7 segment LED display

    I'm trying to get Les Johnsons 2 segment LED multiplexer running - however it's not compiling, rather than using an include I'm putting his code directly into my program as I have to modify it for the chip I'm using (PIC16F88) and find it more conveniant to have one file instead of 2.

    The compile issue is coming up on line 109 - which is a blank line just after Les's code finishes and mine begins, it says it's a syntax error - when it's just a blank line??? If I delete the line it says line 108 has a syntax error.

    I also cannot see how it gets to the Display: section of the code as i can't see any gosub pointing it there I'm using code designer lite and PBP2.46 ANy help you could give me would be greatly appreciated.

    Thanks

    ' Common Cathode seven segment display multiplexer Include file
    ' Displays the contents of the variable D_NUMBER on TWO common cathode displays
    ' using a TMR0 interrupt every 13ms (assuming a 20Mhz oscillator)
    ' ************************************************** *********************

    @ DEVICE PIC16F88 INTRC_OSC, WDT_OFF, MCLR_OFF, BOD_ON
    ' ** Declare the Variables **
    b0 VAR WORD
    LEDS VAR BYTE ' The amount of LEDs in the display
    O_C VAR BYTE ' Used by the interrupt for time sharing
    D_Number VAR BYTE ' The number to display on the LEDS
    DP VAR BYTE ' Position of the decimal point
    Disp_Patt VAR BYTE ' Pattern to output to PortC
    Num VAR BYTE[2] ' Array to hold each digits value
    Digit0 VAR PORTA.2 ' Controls the first DIGIT on the LED
    Digit1 VAR PORTA.3 ' Controls the second DIGIT on the LED

    ' ** Declare the bits and flags of the various registers **

    T0IE VAR INTCON.5 ' Timer0 Overflow Interrupt Enable
    T0IF VAR INTCON.2 ' Timer0 Overflow Interrupt Flag
    GIE VAR INTCON.7 ' Global Interrupt Enable
    PS0 VAR OPTION_REG.0 ' Prescaler division bit-0
    PS1 VAR OPTION_REG.1 ' Prescaler division bit-0
    PS2 VAR OPTION_REG.2 ' Prescaler division bit-0
    PSA VAR OPTION_REG.3 ' Prescaler Assignment (1= assigned to WDT)
    ' (0= assigned to oscillator)
    T0CS VAR OPTION_REG.5 ' Timer0 Clock Source Select (0=Internal clock)
    ' (1=External PORTA.4)
    ADCON0 = %1100000 'turn ad convertor off
    ADCON1 = %10000110 'Right justify result set digi
    OSCCON = %01100000 'Set internal osc to 8MHz
    ANSEL = %00000000

    ' ** THE MAIN PROGRAM STARTS HERE **

    ' Set TMR0 to interrupt
    GIE=0 ' Turn off global interrupts
    While GIE=1:GIE=0:Wend ' Make sure they are off
    PSA=0 ' Assign the prescaler to external oscillator
    PS0=1 ' Set the prescaler
    PS1=1 ' to increment TMR0
    PS2=1 ' every 256th instruction cycle
    T0CS=0 ' Assign TMR0 clock to internal source
    TMR0=0 ' Clear TMR0 initially
    T0IE=1 ' Enable TMR0 overflow interrupt
    GIE=1 ' Enable global interrupts

    ON INTERRUPT GoTo Mult_Int ' Point to the interrupt handler

    TRISB=0 ' Make PortB outputs
    TRISA.3=0:TRISA.2=0 ' Make only the specific bits of PortB outputs


    PORTB=0:PORTA=0 ' Clear PortB and PortA
    O_C=0 ' Clear the time share variable

    GoTo Over_MULTIPLEXER ' Jump over the subroutines

    ' Build up the seperate digits of variable D_NUMBER
    ' into the array NUM. Each LED is assigned to each array variable.
    ' LED-0 (right) displays the value of NUM[0]
    ' LED-1 (middle) displays the value of NUM[1]
    ' The decimal point is placed by loading the variable DP
    ' with the LED of choice to place the point (0..2). where 1 is the farthest right LED,
    ' and 0 disables the decimal point.
    Display:
    For LEDS=1 TO 0 STEP -1 ' Loop for 2 digits (0-99)
    Disable ' Disable the interrupt while we calculate
    Num[LEDS]=D_Number DIG LEDS ' Extract the seperate digits into the array
    IF D_Number<10 AND LEDS=1 Then Num[LEDS]=10 ' Zero Suppression for the second digit
    Enable ' Re-enable the interrupt
    Next
    Return

    ' INTERRUPT HANDLER
    ' Multiplexes the 2-digits
    '
    Disable ' Disable all interupts during the interrupt handler
    Mult_Int:
    LookUp Num[O_C],[63,6,91,79,102,109,124,7,127,103,0],Disp_Patt ' Decode the segments for the LED
    ' Process the first display (farthest right)
    IF O_C=0 Then ' If it is our turn then
    Digit1=0 ' Turn OFF the second LED
    PORTB=Disp_Patt ' Place the digit pattern on portC
    IF DP=1 Then PORTB.7=1 ' Check the value of DP and Turn ON the decimal point
    Digit0=1 ' Turn ON the first LED
    EndIF
    ' Process the second display
    IF O_C=1 Then ' If it is our turn then
    Digit0=0 ' Turn OFF the first LED
    PORTB=Disp_Patt ' Place the digit pattern on portC
    IF DP=2 Then PORTB.7=1 ' Check the value of DP and Turn ON the decimal point
    Digit1=1 ' Turn ON the second LED
    EndIF

    O_C=O_C+1 ' Increment the time share counter
    IF O_C>=2 Then O_C=0 ' If it reaches 3 or over then clear it

    T0IF=0 ' Reset TMR0 interrupt flag
    Resume ' Exit the interrupt
    Enable ' Allow more interrupts

    Over_MULTIPLEXER: '*** MY CODE BEGINS HERE ***

    For b0 = b0 + 1

    IF b0 > 10000 Then
    D_Number = D_Number + 1
    b0 = 0
    EndIF

    IF b0 > 5000 Then
    DP = 2
    Else
    DP = 1
    EndIF

    IF D_Number > 99 Then D_Number = 0

    GoTo Over_MULTIPLEXER

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Well... the first line of your code is:

    Code:
    '*** MY CODE BEGINS HERE ***
    
    For b0 = b0 + 1
    Is this supposed to be the beginning of a "FOR... NEXT" or is that "FOR" in there by accident?

    Arch
    "Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Sweet thanks arch - I'd just overlooked it, it's compiled now, however it came up with a different error: INLINE~1.ASM 81 : [212] Extra Tokens on End of Line

    What does this mean?

    Thanks

  4. #4
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Here's what error 212 means (from the help file "PM.TXT" in the PBP folder):
    212 Extra Tokens on End of Line

    Some initial portion of the current line assembled correctly, but
    additional assembly tokens remain unprocessed. This is often the result of
    a syntax error (extra parameters, misplaced or missing punctuation, etc.).
    Code is generated for the correct initial portion of the line.
    And here's the cause...
    Code:
    @ DEVICE PIC16F88 INTRC_OSC, WDT_OFF, MCLR_OFF, BOD_ON
    There should be a comma after "PIC16F88"...
    @ DEVICE PIC16F88, INTRC_OSC, WDT_OFF, MCLR_OFF, BOD_ON


    There's still the issue of never getting to the "Display" subroutine though.

    Arch
    Last edited by Archilochus; - 20th June 2006 at 02:40.
    "Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Thanks - got it sorted, I just had to put a gosub in my code to point to display anytime I wanted the display to update

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. 7 segment digit problem (using Mister E's code)
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th September 2005, 20:25
  5. WRITE not working
    By servo260 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 29th December 2004, 02:02

Posting Permissions

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