TENGO UN PROBLEMA EL MICROCODE NO SE NO RECONOCERA LAS DIRECCTIVAS DE EL MPLAB __CONFIG ........
PUES ME BOTA ERROR A LA HORA DE COMPILAR NO ES POR LA VERSION DEL PBP
NO SE POR Q SERA
ESTE CODIGO LO BAJE DE LA PAGINA DE MELABS Y ES ESTE
" Lamp dimmer
" ===========
"
" File name : LampDim.bas
" Company : Mister E
" Programmer : Steve Monfette
" Date : 23-12-2004
" Device : PIC12F675
"
"
" This program is use to dim intensity of an AC line load
" like lamp, motor and other. Developped for 60 Hz line.
"
" This allow to increase or decrease intensity.
" If the user doesn"t held at least 0.5 sec:
" 1. "Increase" : we will set the output for full brightness
" 2. "Decrease" : we will turn off the output
"
"
" The software need :
" 1. A full wave signal from the AC line on GP4
"
" The software use :
" 1. TIMER1 overflow to check if pushbutton are hold for
" more than 0.5 Sec
" 2. Interrupt on GP4 (AcLine input) to synchronise Triac
"
"
" Device programming mode and hardware definition
" ===============================================
" Using Internal Clock, no clock out
" Enable Watch dog timer
" Disable MCLR pin
" Enable Power-up timer
" Enable Brown-out detect
"
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _PWRTE_ON & _BODEN_ON
"
"
TRISIO = %11111011
OPTION_REG 0.7 = 0 " Enable pull-ups
WPU=%00000011 " Enable pull-ups on GP0, GP1
CMCON = 7 " Disable analog comparator
ANSEL = 0 " Disable analog converter
Pb_Inc var GPIO.0 " Input for INCREMENT/ON push button
Pb_Dec var GPIO.1 " Input for DECREMENT/OFF push button
Triac var GPIO.2 " Output to TRIAC gate
ACLine var GPIO.4 " Input for the FullWave rectify AC line
"
" Software definition
" ===================
"
"
"
MaxDelay var word
TriacDelay var Word
Debounce_AutoRepeatDelay var word
FullBright var bit
"
"
" Interrupts definition
" =====================
"
"
"
INTCON=%10001000 " Enable interrupt on GPIO change
IOCB 0.4 = 1 " Enable interrupt on GP4 change
PIE1 0# = 0 " disable TMR1 overflow interrupt
T1CON=%00110100 " Set TIMER1
" prescaler 1:8
" internal clock (Fosc/4) 1MHZ
" synchro internal
" we will use TIMER1 overflow
" $ffff * 8* (1/(4MHZ / 4)) = 0.524 Sec
On INTERRUPT GoTo ACDetect
"
" Hardware and variable initialisation
" ====================================
"
"
maxdelay = 6000 " Set Maximum delay (set to 8000 for 50Hz)
FullBright = 0 " disable Full Brightness flag
triac = 0 " disable Triac Gate
triacdelay = 0 " Set delay to minimum
GoSub ResetTimer1 " reset Timer1
"
" Main
" ====
" Get entry from user to Increment of Decrement intensity
"
"
start:
"
" Test Increment push button
" --------------------------
" If hold more than .5 Sec, increment triac gate delay by 500 uSec
" case else Full brightness at output
"
While Pb_inc = 0
GoSub TestTimer1 " test status of TIMER1
while (Pb_inc==0) AND (PIR1.0==0) "loop while holding push button
"and no TIMER1 overflow
Wend
if PIR1.0==1 then " If timer overflow (pushbutton hold for > 0.5 sec),
T1CON 0# = 0 " disable TMR1
GoSub Debounce_AutoRepeat
If (triacdelay < maxdelay) Then
triacdelay = triacdelay + 500 "increment Triac gate delay
Else
triacdelay = maxdelay " if triacDelay>MaxDelay,
FullBright = 1 " set the full brightness Flag
End If
Else
triacdelay = maxdelay " If pushButton was hold less than .5 sec
FullBright = 1 " Set the full brightness flag
End If
Wend
GoSub ResetTimer1
"
" Test Decrement push button
" --------------------------
" If hold more than .5 Sec, increment triac gate delay by 500 uSec
" Case else, turn off output
"
While Pb_dec = 0
GoSub TestTimer1 " Test status of TIMER1
while (Pb_dec==0) AND (PIR1.0==0) "loop while holding push button
"and no TIMER1 overflow
Wend
if PIR1.0==1 then " If timer overflow (pushbutton hold for > 0.5 sec),
T1CON 0# = 0 " disable TIMER1
GoSub Debounce_AutoRepeat
If (triacdelay > 0) Then
FullBright = 0 " Reset TRIAC always ON flag
triacdelay = triacdelay - 500
End If
Else
FullBright = 0 " Reset TRIAC always ON flag
triacdelay = 0
End If
Wend
GoSub ResetTimer1
GoTo start
"
"
" TestTimer1
" ----------
"
" Enable TIMER1 if :
" not enable and not in overflow
"
TestTimer1:
if (T1CON.0==0) AND (PIR1.0==0) then "if TIMER1 not enable
"and TIMER1 not overflow
T1CON 0# = 1 "enable TIMER1
End If
Return
"
"
" ResetTimer1
" -----------
"
" Subroutine to clear Timer1
" 1. Overflow flag
" 2. Disable Timer
" 3. Clear counter
"
ResetTimer1:
PIR1 0# = 0 "clear timer overflow
T1CON 0# = 0 "disable timer
TMR1L=$00 "clear counter
TMR1H=$00 "
Return
"
"
" Debounce_AutoRepeat
" -------------------
"
" Subroutine to debounce push button.
" Also provide kind of auto-repeat when push button
" are held down.
"
" each delay = 20 mSec
" Use of PAUSEUS to be sure getting ACLine interrupt
"
Debounce_AutoRepeat:
For Debounce_AutoRepeatDelay = 1 To 2000
pauseus 10
Next
Return
"
"
" ACDetect
" --------
"
" Interrupt routine called by ACLine (GP4) pin state change
"
disable
ACDetect:
if ACline==1 then " Check for rising edge of AC signal
If triacdelay > 0 Then
triac = 1 " Activate TRIAC
if FullBright==0 then " In case Brightness flag is not set
pauseus triacdelay " do the selected delay
triac = 0 " Disable TRIAC
End If
Else
triac = 0
End If
End If
INTCON 0# = 0 " Clear GPIF (interrupt on GP4 change)
Resume
enable
LOS GRAFICOS LOS PUEDEN VER EN
http://www.melabs.com/resources/samples.htm#submittedAHI HAY UNO QUE DICE DIMMER.ZIP ESTA CON EL DIAGRAMA
LA VERDAD NO SE QUE PUEDA SER ALGUN INCLUDE QUIZAS QUE EL PBP TENGA DIFERENTE AL MPLAB LA VERDAD NO SE O COMO SOLUCIONAR ESO N SE SI SERA POR EL MICROCODE BUENO AGRADECERIA UNA RESPUESTA