[En-Nut-Discussion] NutOS system timer for Mega2561
Henrik Maier
hmlists at focus-sw.com
Wed Aug 23 05:38:48 CEST 2006
PragmaLab wrote:
> Hello all,
>
> due to weird timer behaviour of our freshly ported application (Mega128 ->
> Mega2561), I came accross '\arch\avr\dev\ostimer.c' and discovered that no
> longer Timer0 is used as the system timer but Timer2:
>
> I might have missed some postings on this subject, but searching the Nut
> Archives did not help me much
> 1) does anybody now the reason for this change (Timer0->Timer2)?
I am the culprit. I implemented usage of Timer2 for the AT90CAN128 MCU
when I ported Nut/OS to that CPU over a year ago. As the Mega2561
features also the new register layout like the AT90CAN128, I assume
Harald kept it like that.
Refer to Changelog entry in arch/avr/dev/ostimer.c, Rev 1.6.
The reason for using Timer2 instead of Timer0 is quite simple to
explain: Check the document "AVR096: Migrating from ATmega128 to
AT90CAN128" and you find that the functional equivalent of ATmega128's
Timer0 is now Timer2 for the new architectures. Atmel likes renaming
things. Port pins, Register bits, device names, timers indices etc. They
may have a special department dedicated on renaming things even though
they are functional the same.
From the document AVR096: "The Timer/Counter2 of ATmega128 becomes
Timer/Counter0 in AT90CAN128. The features of the Timer/Counter are
maintained. The I/O pin locations remain unchanged". Vice versa applies.
Also Timer2 needs to be used for these AT90CAN128/Mega2561
architectures in order to use an external oscillator on port pins PG3
and PG4.
Hope this explains it. I agree that this should be pointed out in the
documentation somewhere.
Henrik
http://www.proconx.com
More information about the En-Nut-Discussion
mailing list