do you want to change frequency or duty cycle?
do you want to change frequency or duty while your program's runing?
what about if you enable watch dog timer???
BTW at 38KHZ, If i refer to PIC16F628's datasheet :
@ 20Mhz,38KHZ 50% duty cycle:
period = 2.63 uSec
duty = 512
Code:
PR2 = 130
CCP1CON = %00001100 ' 2 LSB of 512 at bit 5 & 4
' PWM mode bit 3 & 2
CCPR1L = 128 ' 8 MSB of 512
TRISB=0
T2CON = %00000100 ' set timer2 prescaller to 1:1
what about now...
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks