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?