Wrong Frequency
Hi Everyone;
I've got this code, and it's working fine, however the frequency of the pwm mesured with the oscilocope it's half the frequency configured.
It is suposed to have 5Khz, however i've got 2.5Khz.
Can anybody tell me what i'm doing wrong in the code?
PIC12F683
Code:
Define OSC 8
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BOD_OFF
' PINOUT 1 = IN; 0 = OUT
' ====================================================================
'76543210
TRISIO = %00000001
'76543210
GPIO = %00000000
ANSEL = 1 'GP0 ANALOG
VRCON = 0 'VREF OFF
CMCON0 = 7 'COMPARATOR OFF
ADCON0 = %10000000 'RIGHT JUSTIFY - 128
PR2 = %00011000 'SET 24 - 5000Hz - 8Bits
T2CON = %00000110 'TIMER2 ON - PRESCALER 1:16 - Max Duty Value 100 - 1% Step
CCPR1L = %00000000
CCP1CON = %00001100 'PWM ON
Thanks
Thanks and Regards;
Gadelhas
Bookmarks