Welcome. Please log in or register.

140 khz square wave on the atmega328
DAVID Posted: 28 Oct 2018, 08:10 PM
avrs + midi = best diy synths

Posts: 237
Joined: 10-September 17
hi, since past year i was doing a mist maker with arduino/atmega328
but i was not able to create the required 140 khz, how can i create one?

mit Posted: 29 Oct 2018, 05:10 PM
yeah whatever

Posts: 405
Joined: 4-May 16
140kHz should not be too hard to produce. You could probably do it with delay routines and toggling pins, but the proper way to do it is with one of the hardware timers.

Page 99 of the atmega328p datasheet says this about timer 0:

(User posted image)

It takes a bit of poking around with the registers to configure it right, but with this there should be no problem generating any frequency up to 8Mhz.


Sign in to post a reply.