New PMW code for Uno/AVR targets

For general Flowcode discussion that does not belong in the other sections.
Post Reply
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

New PMW code for Uno/AVR targets

Post by medelec35 »

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
Martin

viktor_au
Posts: 52
Joined: Wed Jul 12, 2023 7:09 am
Has thanked: 8 times
Been thanked: 17 times

Re: New PMW code for Uno/AVR targets

Post by viktor_au »

Hi Medelec
All good, works OK.
Thank you.
Attachments
Nano_22Mar25_2.jpg
Nano_22Mar25_2.jpg (64.53 KiB) Viewed 871 times

Post Reply