would fail to correct the fuses and setup the interruption, but more or less the idea was so (I have to find where I have the complete original program that works well) ... ¨ I understood correctly?
Code:
'OPTION_REG =%00111111
PORTA=0:TRISA=%00000001
PORTB=0:TRISB=%00000000
PORTC=0:TRISC=%00000000
PORTD=0:TRISD=%00000000
ADCON1= %10001110 '
T2CON = %00000101
PR2=249
'-----------------------------------------------------------------
@ DEVICE PIC16F877
@ DEVICE PIC16F877, WDT_OFF
@ DEVICE PIC16F877, PWRT_OFF
@ DEVICE PIC16F877, PROTECT_OFF
@ DEVICE PIC16F877, XT_OSC
DEFINE OSC 4
'**** configuracion canal ADC (ADC chanel setting) ***********
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 1
DEFINE ADC_SAMPLEUS 3
'*********** Configuracion HPWM (HPWM PRESETING) *************
DEFINE CCP1_REG PORTC
DEFINE CCP1_BIT 2
DEFINE CCP2_REG PORTC
DEFINE CCP2_BIT 1
HAM var word
X VAR WORD
DUTY VAR BYTE
CCP1CON.2=1
CCP1CON.3=1
On Interrupt Goto int_TIMER0
INTCON = %10100000
Menu:
DUTY=50
GOSUB salida
GOTO Menu
salida:
PR2=((1024-HAM)*/5625)/100+24
X=(PR2+1)* DUTY /25
CCP1CON.4=X.0
CCP1CON.5=X.1
CCPR1L=x>>2
RETURN
Disable
int_TIMER0:
ADCIN 0,HAM
INTCON = %10100000
Resume
Enable
regards
Bookmarks