avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] understanding timers


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] understanding timers
Date: Mon, 6 Mar 2006 23:02:08 +0100 (MET)

Timothy Smith <address@hidden> wrote:

> that example is fine, i understand what's happening ( i think ) but
> how would i controll the speed of the led blinking? would i use a
> different ISR, such a timer compare?

This example is probably not the best example to learn about timers in
general, as it uses the timer in (phase correct) PWM mode.  For the
classical AVRs (and as the example tries to be as generic as possible,
so it does not go beyond the features of a classical AVR), the
frequency selection options for timers in PWM mode were rather
limited: the IO clock frequency is divided by the prescaler, and then
by either 2 * 256, 2 * 512, or 2 * 1024, for 8, 9, and 10-bit PWM
respectively.

Modern AVRs offer much more options here.  First, there's the choice
between phase correct and fast PWM, and the fixed 8/9/10 bit TOP value
can be replaced by a much more flexible TOP value supplied by ICRx or
OCRxA.  That gives you a much broader range of base frequencies for a
PWM timer, and as the blink frequency in the example is tightly
coupled to the PWM base frequency, would allow you to smoothely change
the blink frequency.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]