Interrupts? WDT?
I've the PIC fading through the spectrum with RGB LED strips connected to the three PWM pins. Yet something keeps resetting the program. The timing of the resets is not consistent - at lease once every 2 mins, sometimes after 30 seconds.
I've turned off the WDT and disabled all interupts - also set all pins to outputs.. still resetting. Have I perhaps done this incorrectly, or missed something?
Any other ideas what could cause this?
Many Thanks!Code:@ DEVICE PIC16F777, INTRC_OSC_NOCLKOUT, WDT_OFF DEFINE OSC 8 OSCCON = %01110010 'see data sheet for INTRC speed setting ADCON1 = 15 ' All I/O pins digital INTCON.7 = 0 ' tunr off all interuppts TRISA = %00000000 TRISB = %00000000 TRISC = %00000000 TRISD = %00000000 TRISE = %00000000 ' Set CCPx pins to outputs TRISC.2=0 ' CCP1 output TRISC.1=0 ' CCP2 output (could also be assigned to RB3) TRISB.5=0 ' CCP3 output ' Set CCP modules to PWM mode CCP1CON = %00001100 ' Mode select = PWM CCP2CON = %00001100 ' Mode select = PWM CCP3CON = %00001100 ' Mode select = PWM ' Set period up for 1.22kHz PWM freq PR2 = $FF pie2.0 = 0 pie2.1 = 0 pie1.2 = 0 ' Set TMR2 up for 1:16 prescale & turn it on T2CON = %00000110 ' TMR2 ON 1:16 prescale ' Word vars for 10-bit value of each PWM duty cycle DutyR VAR WORD ' Channel #1 DutyG VAR WORD ' #2 DutyB VAR WORD ' #3 cyclespeed var byte cyclemax var word cyclespeed = 10 cyclemax = 900 gosub cyclestart 'INTRO SEQUENCE main ChangeGreenUp: Repeat DutyG = Dutyg + 1 gosub colourset pause cyclespeed until dutyg = cyclemax ChangeRedDown: Repeat Dutyr = Dutyr - 1 gosub colourset pause cyclespeed until dutyr = 0 ChangeBlueUp: Repeat Dutyb = Dutyb + 1 gosub colourset pause cyclespeed until dutyb = cyclemax ChangeGreenDown: Repeat Dutyg = Dutyg - 1 gosub colourset pause cyclespeed until dutyg = 0 ChangeRedUp: Repeat Dutyr = Dutyr + 1 gosub colourset pause cyclespeed until dutyr = cyclemax ChangeBlueDown: Repeat Dutyb = Dutyb - 1 gosub colourset pause cyclespeed until dutyb = 0 goto main '--------------------------------------------------------------------------- colourset: CCP1CON.4 = Dutyg.0 ' Setup 10-bit duty cycle as CCP1CON.5 = Dutyg.1 ' a 10-bit word CCPR1L = Dutyg >> 2 CCP2CON.4 = DutyR.0 CCP2CON.5 = DutyR.1 CCPR2L = Dutyr >> 2 CCP3CON.4 = Dutyb.0 CCP3CON.5 = Dutyb.1 CCPR3L = Dutyb >> 2 return '--------------------------------------------------------------------------- cyclestart: dutyR = cyclemax dutyg = 0 dutyb = 0 gosub colourset PAUSE 500 dutyR = 0 dutyg = cyclemax dutyb = 0 gosub colourset PAUSE 500 dutyR = 0 dutyg = 0 dutyb = cyclemax gosub colourset PAUSE 500 dutyR = cyclemax dutyg = 0 dutyb = 0 gosub colourset return '--------------------------------------------------------------------------- END
Bookmarks