[En-Nut-Discussion] Question about ARM register definitions

Harald Kipp harald.kipp at egnite.de
Tue Sep 12 09:54:48 CEST 2006

Personally, I never liked "REG = val". For my taste it hides
too many things. For example, you may have a flag register,
where flags are cleared on each access. Using REG in an expression
may provide unexpected results, depending on compiler
optimizations. On low level port access I'd like to know
exactly what's happening, like wether "REG |= val" will
result in sbi or ldr, orr, str.

Atmel's way used on ARM, providing pointers to register structures,
looks very clean and is easy to use. But the problems with
expressions remain.

Beside that, I'd prefer to keep it the way it is now for
two main reasons:

1. No specific header files are required for assembly language.
That simplifies maintenance a lot.

2. The outx()/inx() allows emulation on PC hardware. It
is more general as well. CPUs may use dedicated I/O busses,
separated from the memory bus.

Indeed several AVR parts in Nut/OS use "REG = val". This needs to
be cleaned up.


At 23:39 11.09.2006 +0200, you wrote:
>while Ethernut defines arm registers like
>#define PIO_PER     (PIO_BASE + 0x00)
>the Atmel examples, FreeRtos and others project use something like:
>typedef volatile unsigned int AT91_REG;// Hardware register definition
>typedef struct _AT91S_PIO {
>         AT91_REG         PIO_PER;       // PIO Enable Register
>} AT91S_PIO, *AT91PS_PIO;
>The ethernut way to define require us to use inr() and outr(), while the
>other way allows to use AT91C_BASE_PIOA->PIO_PER = AT91C_PIO_PA16;
>For the AVR, Ethernut uses the latter way of defining. Is the Ethernut Arm
>way some intermediate way or intended to stay?

More information about the En-Nut-Discussion mailing list