I have noticed on all of my PWM channels that they produce a very fine PWM pulse when a value of zero is loaded? The width is 240ns
Pic24Fj64GB002 10 bit StetDutyCycle = 0
Changing the duty cycle to 1 makes no change.
Changing the duty cycle to 2 changes the pulse width to double time 480ns
Is the compiler not allowing zero?
PWM zero duty cycle not zero?
-
- Posts: 144
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 04, 2020 2:29 pm
- Has thanked: 26 times
- Been thanked: 7 times
-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: PWM zero duty cycle not zero?
Hello,
Yes when the duty is 0 we actually change the value to be 1 instead of 0. We do this as a duty of 0 on the 16-bit PIC hardware seems to generate some strange output waveforms which aren't 0% duty. I've just tried it here as a sanity check and some very odd things happen.
If you must have absolute 0% duty then it might be better to disable the PWM channel instead of assigning 0 duty.
Yes when the duty is 0 we actually change the value to be 1 instead of 0. We do this as a duty of 0 on the 16-bit PIC hardware seems to generate some strange output waveforms which aren't 0% duty. I've just tried it here as a sanity check and some very odd things happen.
If you must have absolute 0% duty then it might be better to disable the PWM channel instead of assigning 0 duty.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel