How can I generate a 20MHz 50% duty square wave on a pin of the Arduino UNO Q board? Is it possible? Which libraries should I use?
Thanks
Claudio
How can I generate a 20MHz 50% duty square wave on a pin of the Arduino UNO Q board? Is it possible? Which libraries should I use?
Thanks
Claudio
In the doc they state PWM frequency is fixed to 500 Hz
So using analogWrite() is not going to cut it.
The Arduino documentation does not publish the complete Zephyr device tree, so there is no authoritative list of which timers are used by Zephyr and which are free. Zephyr assigns timers for PWM and some basic timers cannot generate PWM output. So you would need a close inspection of the device tree for the compiled core to find which timers are available and could be configured for your needs without impacting the rest of the OS...
there is some doc available for the functions and macros used in the Zephyr code, so I would use than in conjunction with the UNO Q core repository to start digging... Might be a long hunt...
If you need it to be accurate I would use a 40MHz MEMS oscillator such as Abracon AMPM series and a 74AC74 to device it by 2, that will give you a stable clock at a 50% duty cycle.
Voltage etc which you did not specify is also important in your choice. This will give you a starting point.
What do you need it for?
If it needs to be constant, build a bit of digital hardware to do it.
Google;
20MHz digital oscillator homebrew
Or look at online component suppliers for 20MHz digital oscillators.
Tom....
![]()
It is for automatic debug pourpose only. I will use an external 5V 20MHz oscillator.
Thanks
Claudio
@berta_64 shared their code in their other topic: