trastikata
Member level 1
Hi,
I am trying to implement a PWM on a PIC18F6585. After setting up the PWM registers I get to control the PWM Period and PWM Duty Cycle successfully.
However when I checked with an oscilloscope it looks like that besides the main PWM frequency of 500kHz there is another lower frequency switching on and off the PWM. The following 2 pictures show the same signal - the normal 500kHz output and the 26Hz on-off of the PWM pin. Any idea what is causing it?
Thank you
I am trying to implement a PWM on a PIC18F6585. After setting up the PWM registers I get to control the PWM Period and PWM Duty Cycle successfully.
Code:
'PWM_SETUP
TRISC.2 = 1 'Configure P1A as input
PR2 = 12 'Set PWM period to 2 uS / 500kHz
CCP1CON = %00001100 'Single PWM output P1A - active high
CCPR1L = 6 'Set PWM duty cycle to 50%
TMR2IF = 0 'Clear Timer2 Interrupt Flag
T2CON = 0 'Timer2 prescaller 1:1
T2CON.2 = 1 'Start Timer2
DelayCS 13 'Wait 13 cycles for Timer2 to overflow
TRISC.2 = 0 'Configure P1A As Output
ECCP1AS = 0 'Clear ECCPASE bit
'Do something else
However when I checked with an oscilloscope it looks like that besides the main PWM frequency of 500kHz there is another lower frequency switching on and off the PWM. The following 2 pictures show the same signal - the normal 500kHz output and the 26Hz on-off of the PWM pin. Any idea what is causing it?
Thank you