The new code allows you to directly set the frequency (PB0 to PB5 = 0.24Hz to 158KHz, PD0 to PD7 = 244Hz to 158KHz) and duty cycle from 0 to 100% in 1% steps.
I plan to add simulation.
If anyone would like to test the code on an uno for example, the I would appreciate feedback comparing to existing PWM component.
You can find an example here
Just bear in mind that you will need to set you own pin within the code, if you don't want to use B2
Timer1 is better as its 10bit, but it can only be used for B0 to B5
You must only have timer1 or timer2 code enabled at any one time.
If both enabled there will be an error is only using annotated functions
Thank you
New PMW code for Uno/AVR targets
-
medelec35
- Matrix Staff
- Posts: 2178
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 662 times
- Been thanked: 738 times