The knowings and experiences of a group of developers.

AVR32 First Discoveries

I started my study on AVR32 architecture, I’m amazed, angry and confused on what I discovered in this short period of time, the typical when your accommodate to awesome ARM architecture.

The development environment for the AVR32 is the infamous AVR Studio 5.0, based on Visual Studio (probably the best IDE that I’ve ever worked with) and have some cool and annoying features. The best feature of AVR Studio is the Visual Assist X plugin, basically that’s the best IntelliSense that I’ve ever used for C/C++ development. The most ridiculous thing that AVR Studio 5 have is claiming to have C++ support because that’s a total lie, when you download there is no C++ support, you have to download a buggy plugin if you want the support.

A cool feature of this IDE is the “Eclipse Like” toolchain settings editor, the problem with this? They removed the option to define the linker script (To those that don’t know, when you don’t define a linker script -T myscript.ld, the linker will use the toolchain defined script), fortunately if you configure in the “other options” the -T switch  with your linker script, it will be used instead of the default.

Nevertheless the AVR Studio 5 IDE seams a very powerful tool if you want build applications for the Atmel boards, but if you want to go deeper you will find some ridiculous bugs and workarounds.

AVR32 Quick Reference for Developers

The AVR32 architecture is divided in two main micro architectures, the AVR32A and the AVR32B. The AVR32A was designed to be cheap, by doing so this microarchitecture doesn’t have a full register bank for interrupt/event treatment. The AVR32B was designed to time sensitive applications, so the interrupts have their own register bank.

NOTE: Throughout this posts I’m only going to talk about AVR32A because the CPU I have is a AT32UC3A3256, AVR32A compatible with floating-point, so every time I refer AVR32 features and explanations I’m talking about AVR32A (for instance the AVR32B boot-loader and memory layout is different from the AVR32A).


There are 15 registers in this architecture they are:

  • R0-R8, general purpose registers.
  • R9-R12, argument registers.
  • R13 – The stack pointer.
  • R14 – The link register.
  • R15 – The program counter

You are probably asking where are the flags and other runtime information, I’ll talk about it later on this blog.

Call Convention

The AVR32 call convention is the follow:

  • R9 to R12 is used for arguments where R12 is the first argument and the R9 the forth. All other arguments must be passed by stack.
  • r8 to R12 are scratch registers.
  • R0 to R7 are preserved registers.
  • R12 is used as the return value.
  • R13 to r15 “architecture hardware” registers.

Processor Modes

AVR32 has 8 different working modes:

  •  Non Maskable interrupt – system events that can’t be ignored, this is design to events like TLB misses.
  •  Exception – the usual CPU exceptions, data abort, bad instruction,etc.
  •  Interrupt 3-0 – four different interrupt modes, being the interrupt 3 the most priority and interrupt 0 the least.
  •  Supervisor – the system mode, design to support operating systems.
  •  Application – the user mode, the only one that don’t have all the running permissions

On AVR32 when an interrupt/event is detected by the CPU, they store R8-R12 automatically leaving plenty of registers to  handle the interrupt/event.

Status Register

The status register is divided in two parts. In the lower halfword are the common execution flags (Carry, Zero, Overflow, etc). In the highest halfword are information about the mode, the interrupt availability and masks. The status register even have a scratch bit for the application to use if needed, that’s a funny feature. For more information check the Architecture Document at Atmel. Throughout the future blog posts I probably will talk about some specific flags that I’m going to use.


  • The stack pointer (R13) is shadowed between Application mode and the system modes (all the other modes).
  • The Status Register is mapped directly on the memory at 0x0.
  • When an event/interrupt is attended the program counter points directly to the current instruction (That’s not true in all architectures, for instance in ARM the PC is one instruction ahead).
  • One cool feature of the AVR32 event treatment is the indirect exception vector, with that you can define your handler where you want (In ARM this handlers have a “fixed” memory location).

Final Comments

The AVR32 documentation is just horrible, there is little information about the “behind the scenes” I had to reverse engineer the call convention and that’s just ridiculous. If they are trying to beat ARM, they must explain what they were doing, they must get the attention of people who want to work with the hardware as much the people who make the applications to run on it.

I see interesting stuff, like the system registers, the four different interrupt modes and the development environment(Visual Studio + Visual Assist X = FTW) but I don’t feel that they care a lot about the developers, they don’t care about the people that want to work just above the hardware, “talking” to it and configuring it. From an application designer view, AVR32 is awesome, they give you all the device drivers and interfaces to talk to the hardware (something that is on going on the new ARM Cortex convention) and with Visual Studio the only difference between coding for PC or AVR32 is that USB JTAG cable connected to your PC.


AVR32 Architecture Manual

32-bit AVR UC3 Application Note


One response to “AVR32 First Discoveries

  1. Pingback: AVR32 First Contact, First Code « Imagination Overflow

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: