Universal Interfaces

The new ATXMEGA controllers have a variety of hardware features and components.

In contrast to the „older“ Attiny and Atmega controllers, the configuration structure („Defines“) from Atmel was fundamentally revised. With ATxmega all registers are consistently and cleanly separated by appropriate namespaces and they use all the same way for the naming of eg bit names, bit groups and configuration registers.

This lets you add these pre-assigned manufacturer „defines“ divided neatly into groups and this are correspondingly more manageable. In the Luna IDE „Defines (window)“ the index has also been a corresponding group expanded view (see picture).

In the Defines-Browser/Editor (IDE)

In the Defines-Browser/Editor is for Atxmega-devices a hirarchical overview available. This overview contains all available hardware-modules, registers, bitfields and configuration constants for the selected device.

A click on an element shows automatically a syntax example on the bottom for the usage in Luna-Source. A double-click on an element insert this to the source code at the current cursor position, including a short description as comment.

Source Level

The universal interface provides a simplified way for the direct configuration of the ATXMEGA Components. This means that all group names represent a hardware component that can be addressed in the source code using the usual dot notation.

Basically, this differs only slightly from the configuration via the Avr class using Avr.<Registername>.<Registerbit>, with the only difference that:

Same name Luna interfaces

Same name Luna interfaces, such as USARTC0 are combined. That both variants using to the same time are possible. The available functions are Luna interface extensions that can be applied to this component (eg „usartc0.ReadByte“ and others).

Application

The access to a component is determined by:

Component.Register[.Bit/Bit group] or
Component.Vector

Here, read and write accesses are possible. Extent that makes sense for each individual component, reveals the datasheet of the controller.

Examples

The Access to the single bit SYNCBUSY in the register STATUS of the component RTC are:

bit = RTC.STATUS.SYNCBUSY  //reading
RTC.STATUS.SYNCBUSY = bit  //writing (make no sense on this bit, only for example)

The access to the bit group PRESCALER (3 Bits) in the register CTRL of the component RTC are:

value = RTC.CTRL.PRESCALER  //reading
RTC.CTRL.PRESCALER = value  //writing

The register can be configured directly without assignment. The AutoComplete provides all associated and possible configurations also here:

RTC.CTRL.PRESCALER.DIV1024  //configure prescaler bitfield
'same per assignment are:
RTC.CTRL.PRESCALER = RTC_PRESCALER_DIV1024_gc

The access to the whole register PER (here: word) of the componente RTC are:

value = RTC.PER  //reading
RTC.PER = value  //writing

Assign a service routine to the interrupt vector OVF_VECT of the component RTC:

RTC.OVF_VECT = name
 
isr name
 ..
endisr