My god ... it's ... it's beautifulJust like a 1960's string of Christmas tree lights, the exact effect I'm after. I can't thank you enough, Darrel!
One last query (I hope) - since I only need 5 output pins I would like to convert this to a 12F683. When I do, I get the 'ol "Redefinition of VAR" error pointing to this line:
The whole code is here:Code:CCPR1 VAR WORD EXT : @CCPR1 = CCPR1L
Since there are no include files, my Google search didn't point to anything other than that. Is this too much to expect from a 12F?Code:'**************************************************************** '* Name : UNTITLED.BAS * '* Author : Ross Waddell * '* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 10/27/2012 * '* Version : 1.0 * '* Notes : PIC12F683 * '* : * '**************************************************************** DEFINE OSC 4 DEFINE BLINKYFREQ 100 ; 10mS periods ' *************************************************************** ' 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 OSCCON = %01100000 ' 4MHz internal osc ;---------------------------------------------------------------- LEDcount CON 5 ; Number of LEDs on the PORT OnTimes DATA 50,22,38,75,17 ; default periods for each Output OffTimes DATA 150,45,38,95,117 ;---------------------------------------------------------------- #DEFINE USE_RANDOM_SEQUENCE ; comment for contiuous Sequence #IFDEF USE_RANDOM_SEQUENCE RND VAR WORD : RND = 13864 MIN_ON CON 15 ; Minimum random ON time MAX_ON CON 115 ; Maximum random ON time MIN_OFF CON 15 ; Minimum random OFF time MAX_OFF CON 200 ; Maximum random OFF time RandPeriod VAR WORD[LEDcount] RandPeriods DATA WORD 1000, WORD 1250, WORD 1500, WORD 1750, 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.5 LoopLED VAR BYTE[LEDcount] OnTime VAR BYTE[LEDcount] OffTime VAR BYTE[LEDcount] x VAR BYTE ;----[Initialize]------------------------------------------------ FOR x = 0 to (LEDcount - 1) ; 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 ANSEL = 0 TRISIO = 0 ; PORTC all OUTPUT ;----[Main Program Loop]---------------------------------------- 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


Just like a 1960's string of Christmas tree lights, the exact effect I'm after. I can't thank you enough, Darrel!


Bookmarks