• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MegaCoreX on ATMega4808 getting milis/micros to work with 20MHz clock



I have a 4808 running Arduino code using the MegaCoreX library. If I run the chip with its internal 20MHz oscillator, millis and micros run too fast. I have tried setting a #define F_CPU value, but it doesn't help.

It works fine if I set the clock to 16MHz, but it would be great if I could use that extra bit of speed the chip is capable of. Does anyone know if this is possible?

Nigel Goodwin

Super Moderator
Most Helpful Member
A quick google finds this page on github:

The highlighted line suggests that millis() only works properly for 8 or 16MHz due to the shift right.

EE World Online Articles