Page 2 of 2
Re: yet another issue, really sorry PWM related.
Posted: Mon Oct 26, 2020 2:44 pm
by Mangy_Dog
stevestrong wrote: Mon Oct 26, 2020 2:28 pm
This behavior is normal according to the reference manual.
There are two ways to solve your issue:
1 - your workaround
2 - choose an update value of 65535 for the timers. In this case, when the compare value is greater than or equal the update value, the output will be a clean "1", without a glitch.
While my work around is probably fine for this project, it is more efficient to get the PWM to behave, as i guess I expect :p
What do you mean about option 2? Choose an update value? My Duty is already set to 65535? "pwmWrite(pin,65535)"
Re: yet another issue, really sorry PWM related.
Posted: Tue Oct 27, 2020 8:47 am
by stevestrong
With
pwmWrite() you set the compare value, not the reload/update value which the compare value is compared with to generate the PWM signal.
Using
TimerX.setOverflow() you can set the reload value of the timer corresponding to the PWM pin.
Re: yet another issue, really sorry PWM related.
Posted: Tue Oct 27, 2020 1:01 pm
by Mangy_Dog
So setting the serOverflow, to 65534 will keep the PIN high with no dip at the top duty cycle?
Re: yet another issue, really sorry PWM related.
Posted: Tue Oct 27, 2020 3:29 pm
by stevestrong
According to the reference manual (see RM0008 page 318 text above figure 84), setting the compare value (pwmWrite()) to a higher value than the reload/update value will keep the output pin high.
So yes, if you setOverflow() to 65534 and pwmWrite() to 65535, this should match your requirement.
P.S. I was wrong in my previous post, the value should be higher than the compare value for "1" at output.
Re: yet another issue, really sorry PWM related.
Posted: Tue Oct 27, 2020 5:20 pm
by Mangy_Dog
stevestrong wrote: Tue Oct 27, 2020 3:29 pm
According to the reference manual (see RM0008 page 318 text above figure 84), setting the compare value (pwmWrite()) to a higher value than the reload/update value will keep the output pin high.
So yes, if you setOverflow() to 65534 and pwmWrite() to 65535, this should match your requirement.
P.S. I was wrong in my previous post, the value should be higher than the compare value for "1" at output.
Cool now i get you... Fair enough to save some effort ill just set the compare one bit down so it keeps it high