How to Figure Out Compile Errors?


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

    Default How to Figure Out Compile Errors?

    I'm trying to port over code from a 12F683 to a 16F687 from this thread but I get the dreaded 'syntax error' and it highlights the 'CCP1CON = %00001011' line. How do I figure out what's really going on? I know this chip has the CCP1CON register and the '1011' is supposed to set the compare mode, special event trigger.

    Code:
    DEFINE OSC 20                ; Set oscillator 20Mhz
     
    #CONFIG
       __config _FOSC_HS & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF
    #ENDCONFIG
    
    ' ***************************************************************
    ' Initialization
    ' ***************************************************************
    
    ANSEL    = 0                 
    TRISA    = %00000100         ; Make PORTA all output except for INT pin
    TRISB    = 0                 ; Make all PORTB pins output
    TRISC    = 0                 ; Make all PORTC pins output
     
    CCPR1val      CON EXT      : @CCPR1val = (OSC*1000000/4)/ BLINKYFREQ
    CCPR1         VAR WORD EXT : @CCPR1 = CCPR1L
    Timer1        VAR WORD EXT : @Timer1 = TMR1L
    CCPIF         VAR PIR1.2
    
    ;-- setup CCP1 and Start Timer1 --
    CCPR1   = CCPR1val          ; set compare value
    CCP1CON = %00001011         ; compare mode, special event 
    Timer1  = 0                 ; clear Timer1
    T1CON.0 = 1                 ; start Timer1
    
    Main:
      HIGH PORTB.0
      pause 1000
      LOW PORTB.0
      pause 1000
      
      goto Main

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


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Quote Originally Posted by RossWaddell View Post
    ... I know this chip has the CCP1CON register ...
    The 16F687 doesn't have a CCP module.
    Therefore, no CCP1CON.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    I downloaded the datasheet before ordering it, and it mentions the CCP1CON register - does that only apply to one of the other chips in the shared PIC16F631/677/685/687/689/690 data sheet?

    Can anyone think of another chip that has a CCP module, USART and 8 output pins on a PORTA/B/C which doesn't have the CCP/Rx pin?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Hi,
    If you look at page 2 of the datasheet you'll find the following table:
    Name:  16F687.GIF
Views: 317
Size:  10.4 KB
    There you'll see that the 16F687 doesn't have the ECCP module. I'm not sure exactly what you're trying to do but if you want 8 outputs can't you split them across two ports? Say PortB.0-3 and PortC.0-3 of the 16F690 (same datasheet), RX is on PortB.4 and the CCP1 on PortC.5 so both of those are avoided.

    Finally, in the code in your first post I don't see BLINKYFREQ being defined anywhere.

    /Henrik.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Datasheet's with combined PICs drive me nuts, but in most cases I've seen so far it's usually just 2 PICs; this is the first time I've run across one which has 6 and only some have ECCP modules (I think the 16F690 has it, which may be why a search through the datasheet comes up with 'CCP1CON'.

    I trimmed the code to test and left out the definition of BLINKYFREQ - even with it back in, though, it still doesn't compile (same reason).

    For the 8 pins together, its because of this cool code from Darrel:

    Code:
    ;----[Main Program Loop]----------------------------------------
    Main: 
        ' Check if flash mode has changed
        IF FlashMode <> Old_FlashMode Then
            Old_FlashMode = FlashMode
            GOSUB SetNavLtsFlashRates
        EndIF 
    
        x = (x + 1) // LEDcount
        PORTB.1(x) = !!(LoopLED(x) < OnTime(x))
        LoopLED(x) = (LoopLED(x) + 1) // (OnTime(x) + OffTime(x))
        #IFDEF USE_RANDOM_SEQUENCE
            IF x < 5 THEN
                RandPeriod(x) = RandPeriod(x) - 1
                IF RandPeriod(x) = 0 THEN
                    READ RandPeriods+(x<<1), WORD RandPeriod(x)
                    RANDOM RND
                    OnTime(x) = (MAX_ON - MIN_ON)* RND.HighByte / 255 + MIN_ON 
                    OffTime(x)= (MAX_OFF - MIN_OFF)* RND.LowByte / 255 + MIN_OFF
                ENDIF
            ENDIF
        #ENDIF
        IF x != (LEDcount - 1) THEN Main
    
    Waiting: IF !CCPIF THEN Waiting
        CCPIF = 0
    GOTO Main
    In this example, it's offset by 1 since PORTB.0 is the INT pin which is being used to detect a button push.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Hi,
    Yes, the table shows the 16F690 having both an ECCP module and an USART. Unfortunately they won't leave you with unrestriced access to PortB.

    If, instead of doing the indexed bit operation ( PortB.1(x) etc ) on the PortB or any other Port, you do them on a BYTE variable (like myLEDS or whatever) you can then, as a final task in the loop take the value of that BYTE variable and split it across two ports. Write the four low bits to PortB.0-3 and the four high bits to PortC.0-3. Not saying that I'm sure it will work, Darrel may be using one of his tricks, but I think it might. Perhaps its worth a try.

    /Henrik.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    I was going to use PORTC on the 16F690.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Hmm, then I'm not following, which doesn't really matter as long as you get what you need but in a previous post you wrote
    Can anyone think of another chip that has a CCP module, USART and 8 output pins on a PORTA/B/C which doesn't have the CCP/Rx pin?
    On the 16F690 the RX-pin is on PortB.5 and the CCP1 pin on PortC.5. I thought you were using those pins for their peripheral functions therfore not allowing 8 consecutive bits on either of those two ports - but I've must have misunderstood.

    /Henrik.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: How to Figure Out Compile Errors?

    Sorry for not being clear, Henrik. For the current iteration of the code on a PIC16F88 I'm using PORTB.1-7 (since PORTB.0 is the INT pin which I have hooked up to a button switch) where the CCP1 pin is PORTB.3 but it doesn't matter as I'm only using the compare module, not the capture or PWM.

Similar Threads

  1. Replies: 10
    Last Post: - 11th April 2010, 09:12
  2. Usart compile errors 18F4520
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th May 2009, 23:13
  3. USB PBPL Compile errors
    By Rob in forum USB
    Replies: 11
    Last Post: - 7th April 2008, 08:18
  4. USB Mpasm Compile errors
    By JBrannan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st December 2007, 18:13
  5. Compile errors within macro....
    By forgie in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th September 2005, 19:08

Members who have read this thread : 1

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