Simplifying XMEGA Application Notes

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am writing my first xmega code - actually converting some existing code that uses LEDs, USART, Timers, and extended RAM. I have read most of the xmega application notes and am reading through the associated example code.

There are several new things to learn such as:
1. New register names, mask and bit names. Between the datasheet and the iox1281A1.h file, I can see what needs to be done although I wish I had a handy reference for all the defines in the header file.
2. New facilities in xmega such as configuring the system clock (beats fuses anyday) and EBI.

However I am finding that the example code supplied with an application note actually obscures the problem even more. The example code includes xxx_driver.h/xxx_driver.c which provide a thin abstraction layer over the xmega registers. The emphasis is on thin because this abstraction layer becomes yet another thing to learn. For example:

   void CLKSYS_XOSC_Config( OSC_FRQRANGE_t freqRange,
                         bool lowPower32kHz,
                         OSC_XOSCSEL_t xoscModeSelection )

Two of the parameters take register symbolic values defined in the xmega header file (e.g. iox128a1.h)

   CLKSYS_XOSC_Config(OSC_FRQRANGE_12TO16_gc,
                     false,
                     OSC_XOSCSEL_XTAL_16KCLK_gc );

What I end up doing is reading the example code and then removing this thin "driver" layer to end up with:

OSC.XOSCCTRL = OSC_FRQRANGE_12TO16_gc | OSC_XOSCSEL_XTAL_16KCLK_gc;

Perhaps other people like this thin layer but I think it has virtually no value add as actually increases the learning curve.

There has been discussion previously on an xmega library. These very low-level driver files are not it. What I would like is something much higher level that sets up everything in one API call and returns an error if necessary e.g.

uint8_t avrSetupExternalCrystal(uint8_t freq)

The purpose of this append is not discuss an xmega library but to see if we can make more readable xmega application notes that ease the transition from existing AVR code. Does anyone have this or should we all start to write xmega tutorials for AVR Tutorials forum?

--Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After some tests with adc and timers, I agree

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I have said elswhere these application notes are a master class in how NOT to write application notes.

Whenever I need to examine the code I always merge 3/4 C source files into a single assembler file. This is one of those rare occassions that the assembler code is shorter than the C code (OK I use a couple of Macros - but they are very basic and the same ones used throughout all the application notes).

The problem is more fundemental than just poorly structured application notes. The reason you are forced to use them is that information is missing from the the A Manual.

I look forward to the time when Atmel has sorted out the documentation problems on the Xmega.

It is easy to lose sight of the fact that the XMega is a very new processor. Also the IO subsystem is a complete redesign in an effort to get away from the structural limitations on the earlier AVR families. While this has been very successful the price is a very steep learning curve and lengthy documentation that will take a long time to sort out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Trevor_G wrote:
As I have said elswhere these application notes are a master class in how NOT to write application notes.
You know, I'm really glad other people are having trouble with the Xmegas too. I thought I was just in over my head.

mikeperks wrote:
Perhaps other people like this thin layer but I think it has virtually no value add as actually increases the learning curve.
Nope, I find it completely useless. It's discouraging, in fact. I find it only confusing.

mikeperks wrote:
There has been discussion previously on an xmega library. These very low-level driver files are not it. What I would like is something much higher level that sets up everything in one API call and returns an error if necessary e.g.
uint8_t avrSetupExternalCrystal(uint8_t freq)

The purpose of this append is not discuss an xmega library but to see if we can make more readable xmega application notes that ease the transition from existing AVR code. Does anyone have this or should we all start to write xmega tutorials for AVR Tutorials forum?

Now THAT is what I want to see:
uint8_t avrSetupExternalCrystal(uint8_t freq)

You hit the nail on the head sir. My progress has been slow. The only advice I can get from people (not people on the forum, you guys are helpful. colleagues) is "read the datasheet," "read the application notes." So I've been plowing through but going in circles