Atmega32 generate 1MHz sq. wave

Status
Not open for further replies.

fm101

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
 

Hi,

Yes. Do a datsheet search "fast PWM".

Klaus
 

    fm101

    Points: 2
    Helpful Answer Positive Rating
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.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…