avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] New device support


From: Dmitry K.
Subject: Re: [avr-libc-dev] New device support
Date: Sun, 15 Jul 2007 17:40:02 +1100
User-agent: KMail/1.5

On Saturday 14 July 2007 08:55, Joerg Wunsch wrote:
[...]
> The question now is, what to chose for the name of TCCR0B when it's
> defined as the union/bitfield sketched out above?  If we call that
> TCCR0B, the old way of handling TCCR0B like
>
>       TCCR0B = _BV(CS00) | _BV(CS02);
>
> would be rewritten as
>
>       TCCR0B.byte = _BV(CS00) | _BV(CS02);
>
[...]

A small note: the above expressions are *different*.

The first is "to write the 0x05 value into TCCR0B" and
takes 2 clocks (ldi,out). But the second is "to read TCCR0B,
clear 0x07 field, add 0x05 value and write back to TCCR0B"
and takes 4 clocks (in,andi,ori,out).

Simetimes the such rewriting is wrong, for registers that
contain bits which are cleared by writing of "1" (like
UCSR0A).

Nevertheless I agree, that the existing approach is fraught
with mistakes as Atmel sometimes transfers bits from one register
to another (for example, SE is moved from MCUSR to SMCR).

Dmitry.





reply via email to

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