hi all.my pic16f877a did generate the 125kHz with 50% (get from this forum,thanx) but i don't know how to turn it off.what i mean is if i push the button 1 pic will generate the pwm & when i push the button 2 pic will stop from generate it (on/off the PWM).
here is my coding:
define osc 8
TRISC = 0 'PORTC all outputs
TRISB.5 = 1
TRISB.4 = 1
push1 var portb.5
push2 var portb.4
main:
if push1 = 0 then inject
if push2 = 0 then notinject
goto main
inject:
if push2 = 0 then notinject
PR2 = 15 'Load Period Register
CCPR1L = 8 'Set 50% duty cycle
CCP1CON = %1100 'PWM mode
T2CON.2 = 1 'Start TIMER2
if push2 = 0 then notinject
goto inject
notinject:
if push1 = 0 then inject
????????????????????????????
????????????????????????????
????????????????????????????
if push1 = 0 then inject
goto notinject
i don't know what to fill in the "??????"....i have try to set the TMR2=0, CCP1CON=0 & T2CON.2=0 but it did not work...help me please....
Bookmarks