MCUdude / MiniCore

Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
Other
983 stars 243 forks source link

Support 4.9152MHz clock #299

Closed gauravahuja closed 4 months ago

gauravahuja commented 5 months ago

Add support for 4.9152MHz clock which also provides error free UART for certain baud rates like 38400

MCUdude commented 4 months ago

That's not a very common clock frequency, and of you have a look at an AVR baud rate calculator, 4.9152 MHz isn't a very "good" clock speed to choose in terms of UART compatibility.

Skjermbilde 2024-05-23 kl  20 14 43
gauravahuja commented 4 months ago

Compare it with baud compatibility for 4Mhz clock. 4.9152Mhz offers 0% error rate for many baud rates that you would realistically use for sub 8Mhz clocks.

image
MCUdude commented 4 months ago

Yes, but then again 7.3728 MHz is a better option. If you have to use that particular frequency, you can always use PlatformIO.

gauravahuja commented 4 months ago

@MCUdude There are a few things I would like to point out

MCUdude commented 4 months ago

Your comment about 4.9152MHz not being very "good" clock speed isn't objectively true compared to other frequencies supported by MiniCore.

True, clock frequencies, like 4 and 8 MHz, perform worse than 4.9152 MHz when using "standard" baud rates like 115200, but performers perfect at non-standard ones like 250000 and 500000.

But then what is the point of supporting multiple clock frequencies that are not better?

It depends on the application. A "round" clock like 4 MHz performs excellent with "round" baud rates, like 250000 baud, like I mentioned earlier.

Platform IO uses MiniCore as part of its build process so I cannot readily use it without support for clock frequency I need.

You can easily override the clock frequency (F_CPU) when building using PlatformIO. PlatformIO is very flexible, much more than Arduino IDE.

I am willing to invest time and energy into adding support for a new clock frequency If you are willing to include that in MiniCore.

But I see no point in adding a new clock frequency to the list when there are better alternatives for both standard and non-standard baud rates. Why not change to a more common frequency rather than pushing toward adding this not-so-common, not-all-that-great clock that isn't very common to use with AVRs?