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

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

RE: [avr-gcc-list] problems with timer0 on atmega128


From: Artur Lipowski
Subject: RE: [avr-gcc-list] problems with timer0 on atmega128
Date: Thu, 30 Jan 2003 08:54:48 +0100

Assuming (rather slow) 4Mhz crystal your interrupt will be called about 15
times per second, and your first internal delay loops will take about 0.25
microsecond. You should use scope or be very fast to detect blinks 8-)
You should clear timer on compare match or use apopriate timer settings or
use 16 bit timer for longer periods ("one shot" work).
You start interrupts before timer is set up so no repeatable behaviour of
the timer can be assumed.

Delay loops are not needed at all, just use/reprogram timer(s) for all
delays.
Do not use outb.
Do not use crypric values when setting control registers eg outb(TCCR0, 5),
there are defined names for all bits.
When you declare variable static you not need to initialize it to 0.
Do not use static when not needed (eg. for max and count) to allow compiler
optimization (especially in size).
Insted of setting whole ports just define pins connected to leds and change
only these bits in IO ports.

Regards
--
Artur Lipowski

avr-gcc-list at http://avr1.org



reply via email to

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