yet another issue, really sorry PWM related.

Post here all questions related to LibMaple core if you can't find a relevant section!
User avatar
Mangy_Dog
Posts: 90
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: yet another issue, really sorry PWM related.

Post 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)"
Just a dogs body developer, mostly making props and stuff...
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: yet another issue, really sorry PWM related.

Post 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.
User avatar
Mangy_Dog
Posts: 90
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: yet another issue, really sorry PWM related.

Post by Mangy_Dog »

So setting the serOverflow, to 65534 will keep the PIN high with no dip at the top duty cycle?
Just a dogs body developer, mostly making props and stuff...
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: yet another issue, really sorry PWM related.

Post 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.
User avatar
Mangy_Dog
Posts: 90
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: yet another issue, really sorry PWM related.

Post 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
Just a dogs body developer, mostly making props and stuff...
Post Reply

Return to “General discussion”