I've tried adapting Darrel's example from this thread, but no luck with a PIC16F1825 - PORTC.0-3 do not blink (PORTC.0-2 are off; PORTC.3 is on) but PORTC.4 blinks properly. What am I doing wrong here? I've had to adapt Darrel's code for the PIC16F1825 and reduced the number of blinkies to 5 from 8.
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 : PIC16F1825 * '* : * '**************************************************************** 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 _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF __config _CONFIG2, _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF #ENDCONFIG OSCCON = %01101000 ' 4MHz internal osc DATA 50,22,38,75,17;,40,62,13 ; default periods for each 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 LoopLED VAR BYTE[5] LoopCON VAR BYTE[5] x VAR BYTE ;----[Initialize]------------------------------------------------ FOR x = 0 to 4 ; load the periods from EEPROM READ x, LoopCON(x) 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 ANSELC = 0 TRISC = 0 ; PORTC all OUTPUT ;----[Main Program Loop]---------------------------------------- Main: ;x = (x + 1) // 8 x = (x+1)&4 PORTC.0(x) = !(LoopLED(x) < LoopCON(x)) LoopLED(x) = (LoopLED(x) + 1) // (LoopCON(x) << 1) IF x != 4 THEN Main Waiting: IF !CCPIF THEN Waiting CCPIF = 0 GOTO Main




Bookmarks