|
|
View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
PWM module, right way to synchronous start and stop? |
Posted: Tue Jan 22, 2019 1:48 pm |
|
|
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: 19539
|
|
Posted: Tue Jan 22, 2019 2:09 pm |
|
|
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. |
|
|
|
|
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
|