View previous topic :: View next topic |
Author |
Message |
dani
Joined: 02 Jun 2004 Posts: 16 Location: Pakistan
|
2 HPWM problem..? |
Posted: Thu Oct 20, 2005 3:01 am |
|
|
Hello,
When I keep one channel of hpwm in 16f877 at fixed duty cycle value and change the duty cycle of second channel constantly then first channel's pwm output jitters(shakes). y is this.
Code: |
void main()
{
int8 d1,d2;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_16, 127, 1);
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
set_pwm1_duty(1);
delay_ms(500);
set_pwm2_duty(100);
while (1)
{
for (d1=1;d1<=100;d1++)
{
set_pwm1_duty(d1);
delay_ms(50);
}
for (d1=100;d1>=1;d1--)
{
set_pwm1_duty(d1);
delay_ms(50);
}
} |
|
|
|
Guest
|
Re: 2 HPWM problem..? |
Posted: Thu Oct 20, 2005 5:04 am |
|
|
BY HPWM I ACTUALLY MEAN THE BUILT IN HARDWARE PWM CHANNELS.
I KNOW THIS PROBLEM CAN BE SOLVED BY MANUPLATING THE ASSOCIATED REGISETERS DIRECT BUT I DONT KNOW THE EXACT CODE. IF ANY ONE CAN PLZ SHARE WITH ME SOME SAMPLE CODE THAT CAN BE HELP FULL FOR ME.
REGARDS |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Oct 20, 2005 6:51 am |
|
|
Are you triggering on the constant channel? |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Thu Oct 20, 2005 7:14 am |
|
|
I haven't worked on dual PWMs on an '877, only on a '458.
I have a hunch that the PR2 register is being changed. This would cause your glitches in any currently running PWMs. Other than that, merely changing the respective duty cycle register should not cause glitches on the other. |
|
|
|