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

PWM on dspic30F

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



Joined: 04 Mar 2009
Posts: 16

View user's profile Send private message

PWM on dspic30F
PostPosted: Mon Mar 16, 2009 7:02 am     Reply with quote

I have PWM working on a dsPic30F6012A. Is there a way to not get the first startup pulse? At each bootup there is a short full-on pulse until the PWM gets into sink and starts back at 0 PWM.

Here's some pseudo code.

10MHZ crystal on XLTx4 (40,000,000 clock)

main()
{
. . .

setup_timer3(TMR_INTERNAL|TMR_DIV_BY_64,780); // 200HZ PWM
setup_pwm_duty(6,0); // using OC6 = pin_D5
setup_compare(6,COMPARE_PWM|COMPARE_TIMER3); // using OC6 = Pin_RD5

. . .

while(1);
}

With the above I get a 200us pulse at bootup, then it goes to zero like it's supposed to while I wait to use the channel. I've tried messing with the timer to see if I could trick it into staying off, but nothing seems to work.

Thanks.
Ttelmah
Guest







PostPosted: Mon Mar 16, 2009 8:14 am     Reply with quote

Try not enabling the timer, till after you have setup the PWM. This is what the MicroChip data sheet suggests.

Best Wishes
nostep



Joined: 04 Mar 2009
Posts: 16

View user's profile Send private message

PostPosted: Mon Mar 16, 2009 11:55 am     Reply with quote

I think I get the pulse when I do this line:

setup_compare(6,COMPARE_PWM|COMPARE_TIMER3); // using OC6 = Pin_RD5

I don't know what else to try.
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