CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

2 HPWM problem..?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dani



Joined: 02 Jun 2004
Posts: 16
Location: Pakistan

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger

2 HPWM problem..?
PostPosted: Thu Oct 20, 2005 3:01 am     Reply with quote

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..?
PostPosted: Thu Oct 20, 2005 5:04 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Oct 20, 2005 6:51 am     Reply with quote

Are you triggering on the constant channel?
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Thu Oct 20, 2005 7:14 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group