[Top][All Lists]

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

Re: [avr-gcc-list] Timer0 problem on AVR butterfly

From: Ned Konz
Subject: Re: [avr-gcc-list] Timer0 problem on AVR butterfly
Date: Fri, 10 Feb 2006 18:36:59 -0800

On Feb 10, 2006, at 3:28 PM, Dave wrote:

Hello All,

I'm having trouble with timer0 on my AVR butterfly.
I'm trying to start the timer right before a routine
and read it once the routine is done. I'm hoping to
print the counted ticks on the LCD, but haven't had
luck at all. The following is my code:

TCCR0A = 1; // system clock frequency will be used
TCNT0 = 0; // initial value for timer
t = TCNT0;

LCD_putc(0, t); // write t on digit 0

Is there something wrong with my code? Are there any
examples you can direct me to? Thank you.

Well, what's t declared as? I assume that it's compatible with TCNT0 (which is an 8-bit register).

In fact, it's hard to tell what exactly the problem is with just that snippet. Also you don't say how you've been unlucky. What happened? What did you observe? What steps did you take to test your ideas as to what might be wrong?

Of course, a LCD_putc() will just put a character whose code is the same as the reading of TCNT0 on the display. And that assumes that there is a character that corresponds to that code. If you want to see a number, you'll have to do some more work.

And remember that this will only measure time delays up to 255 * the clock period. I forget what the Butterfly clock is running at, but

You might want to use Timer1 (though the stock Butterfly code uses it), as it's 16-bits.

I assume you've googled for

"avr butterfly" gcc

to find resources.

One I've found helpful is http://www.siwawi.arubi.uni-kl.de/ avr_projects/#bf_app

Ned Konz

reply via email to

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