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 module, right way to synchronous start and stop?

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



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PWM module, right way to synchronous start and stop?
PostPosted: Tue Jan 22, 2019 1:48 pm     Reply with quote

Hi

Used it a lot, but now it is more important that the sequence is started with a complete pulse and stopped too.

The way from the datasheet is to wait for the used timer interrupt, well i already do that...

My sequence is:
Code:
Setup_timer.
Setup_CCPX.
while (!interrupt_active (Int_Timerx)){;}
Set_pwm1_duty(xx)


This is not the same as from the datasheet, it say clear the TRIS bit and then it will run.

Maybe my explanation is nonsense.


Short, what is the right way?
Ttelmah



Joined: 11 Mar 2010
Posts: 19219

View user's profile Send private message

PostPosted: Tue Jan 22, 2019 2:09 pm     Reply with quote

On most (all?) PIC's, the PWM hardware already does this.
Values won't update from the duty cycle register to the PWM hardware
until the end of the current cycle.
So the cycle will always have a full cycle at the start/end.
What PIC are you using?.
Check the data sheet.

On all but the more basic PIC's, the peripheral overrides the TRIS,
so this cannot be used to control the output.
If you wish to take over control, you have to turn the PWM off first.
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