Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Atmega32 generate 1MHz sq. wave

Status
Not open for further replies.

fm101

Member level 5
Member level 5
Joined
Apr 13, 2020
Messages
81
Helped
1
Reputation
2
Reaction score
4
Trophy points
18
Activity points
591
hi,

Is it possible to generate 1MHz square wave using ATmega32 with 4MHz external oscillator?

thanks
 

The fastest output from a timer is to have it toggle an output pin. On the ATmega16, Timer 2 is an 8 bit timer, and would be a good choice.
Referring to the ATmega16 datasheet:
Set the OC2 pin as an output.
Set the Timer 2 control registers to:
Set Timer2 to toggle OC2 on compare match.
Set the timer2 to CTC mode.
Set the Timer2 prescale to no prescaling.
Set the output compare register, OCR2, to 1, for maximum frequency, to see if it is equal to or greater than 1 megahertz.
Adjust the OCR2 value as needed.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top