Quote Originally Posted by Darrel Taylor View Post
The 12F629 doesn't have a CCP module.
You'll be better off with the 12F683.

Don't comment the CCPR1 line in the .inc file. Comment the one in the blinky code.
Code:
CCPR1         VAR WORD EXT : @CCPR1 = CCPR1L
I converted the code to use a 12F683 PIC but the LEDs come on and then stay on (although not all 5; some stay off). Is it because of the input-only GP4/MCLR?

Code:
' Basic blinky code provided by Darrel Taylor
' See forum posting here:
' http://www.picbasic.co.uk/forum/showthread.php?t=17299&p=116934#post116934

' ***************************************************************
' Pin Connections
' ***************************************************************

' GP5    -> pin 2             -> R4 -> BL4
' GP4    -> pin 3             -> R5 -> BL5
' GP3    -> pin 4             -> MCLR (input only, 'dummy' BL6)
' GP2    -> pin 5             -> R1 -> BL1
' GP1    -> pin 6             -> R2 -> BL2
' GP0    -> pin 7             -> R3 -> BL3

' Initialization
' ***************************************************************

DEFINE OSC 8             ' Set oscillator 8Mhz

DEFINE BLINKYFREQ 100    ' 10mS periods

OSCCON   = %0111
CMCON0   = %0000111	     ' Turn off comparators
ANSEL.0  = 0             ' Digital only
ANSEL.1  = 0             ' Digital only
ANSEL.2  = 0             ' Digital only
ANSEL.3  = 0             ' Digital only
ADCON0.0 = 0             ' ADC is disabled
TRISIO   = %00000000	 ' Make all GPIO pins output

' ***************************************************************
' Device Fuses
' ***************************************************************
' PIC chip data sheets can be found here: C:\Program Files\Microchip\MPASM Suite
      
#CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BOD_ON & _CP_OFF & _CPD_OFF
#ENDCONFIG

LEDcount    CON 6            ; Number of blinking LEDs
                             ; (includes 'fummy' LED on GP3/MCLR pin, 
                             ; rates defined separately below)
                                         
'                 BL3,BL2,BL1,BL6,BL5,BL4
'                 --- --- --- --- --- ---
' default "on" periods for each output
OnTimes     DATA  50 ,82 ,50 ,33 ,133, 2
' default "off" periods for each output
OffTimes    DATA 150 ,45 ,50 ,33 ,22 ,48

;----------------------------------------------------------------
#DEFINE USE_RANDOM_SEQUENCE           ; comment for contiuous Sequence
#IFDEF USE_RANDOM_SEQUENCE            
    RND     VAR WORD : RND = 13864
    MIN_ON  CON 33                    ; Minimum random ON time
    MAX_ON  CON 100                   ; Maximum random ON time
    MIN_OFF CON 33                    ; Minimum random OFF time
    MAX_OFF CON 100                   ; Maximum random OFF time
    RandPeriod VAR WORD[LEDcount]
    RandPeriods DATA WORD 1000, WORD 1250, WORD 1500, WORD 500, WORD 2000, WORD 2000
#ENDIF

CCPR1val      CON EXT      : @CCPR1val = (OSC*1000000/4)/ BLINKYFREQ
;CCPR1         VAR WORD EXT : @CCPR1 = CCPR1L
Timer1        VAR WORD EXT : @Timer1 = TMR1L
CCPIF         VAR PIR1.2

LoopLED       VAR BYTE[LEDcount]
OnTime        VAR BYTE[LEDcount]
OffTime       VAR BYTE[LEDcount]
x             VAR BYTE

' ***************************************************************

;----[Initialize on/off periods & random sequencing (if enabled)]---------------
FOR x = 0 to (LEDcount)           ; Load the periods from EEPROM
    READ OnTimes+x, OnTime(x)
    READ OffTimes+x, OffTime(x)
    #IFDEF USE_RANDOM_SEQUENCE
        READ RandPeriods+(x<<1), WORD RandPeriod(x)
    #ENDIF
NEXT X

;-- 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: 
    x = (x + 1) // LEDcount
    GPIO.0(x) = !!(LoopLED(x) < OnTime(x))
    LoopLED(x) = (LoopLED(x) + 1) // (OnTime(x) + OffTime(x))
    #IFDEF USE_RANDOM_SEQUENCE
        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
    IF x != (LEDcount - 1) THEN Main

Waiting: IF !CCPIF THEN Waiting
    CCPIF = 0
GOTO Main