Just thinking of using an XMega, any advice?

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

Hi All
I am planning on using an XMega as a secondary device on a board we are making, I was using an ATMEGA128, but needed more USARTS, also the A/D and D/A capabilities look good.

What are the basic things I should look out for when switching from 8bit AVR to the Xmega

(using C, AVR Studio 5)

thanks

Phil

_________________________________

www.proficnc.com
_________________________________
Go Aussie Go!!!

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

proficnc wrote:

What are the basic things I should look out for when switching from 8bit AVR to the Xmega

One of the main difference is the XMEGA power supply voltage range.

Ozhan KD
Knowledge is POWER

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

Quote:

also the A/D ... capabilities look good.

If the design had worked. You need to see:

http://blog.frankvh.com/2010/01/...

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

The Xmegas still have a fair number of hardware errata, so check the errata section of the data sheet closely.

The I/O pins are configured a bit differently, and have several additional modes. Not a problem, just something to remember when you start porting / writing code for it.

The ADC section is one of the modules on the chip that perhaps isn't performing quite as advertised. There are several threads about this. If you have specific needs, then read the threads closely to see if themode you desire is fully functional at the conversion rate you desire.

If you are using the Xmegas for their 8 USARTs then you have an interesting decision regarding using the internal osc or an external Xtal. On the Megas and Tinies one would generally use an external Xtal or have their software calibrate the clock for reliable operation, as their internal RC oscillators are +/- 10%, (off the top of my head...).

The Xmega's internal oscillators are much more accurate, and in theory one could do USART comms without an external Xtal. If your operating temperature range is wide, however, one might still consider using one. I've got several boards that communicate fine with a PC, XBee, Bluetooth, etc., using the internal clock(s). That said, my main development board has pads for an Xtal and caps, should I wish to add it. You may wish to do the same if you are laying out your own board. Having the pads doesn't mean you need to populate them.

The interrupt system is different, also. Fixed priority or round-robin, High, medium, and low priorities, etc. Another nice improvement.

Once you start working with the chip read About the Event System. Then read it again. Then read it again. Then give it a try. Very cool. I tend to think of it as a hardware interrupt system for passing data on a dedicated bus. That is probably not an accurate description, but it conveys the concept. It lets you pass pass some data or triggers about without using a formal ISR, and can change how you structure your programs.

Lots of on board clocks to work with.

Migration from a Mega to an Xmega takes a bit of work, especially if one wishes to use some of the new features. Migration within the Xmega series is trivial. All of the modules use the same pins & addresses, etc., so it is just a matter of whether the chip includes the module desired.

The higher clock rate is nice for some projects. Don't forget that the Xmega boots at 1 MHz, and you then set up you clock source, (and frequency, if using the PLL, etc.), in your start up code.

There are many other features, this just scratches the surface. Get one and start working with it. There is the Atmel Xplain board, and Gabotronic's various boards, as well as others.

The biggest "difficulty" with the Xmega, for me at least, is hand soldering the chips. I still fine this to be challenging. Not an issue, however if for production, or if you use somebody else's development board for your initial work.

JC

Edit: Xmega's start up at 1 MHz...Not sure what I was thinking...

Last Edited: Mon. Apr 11, 2011 - 11:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for good advice from DocJC.Also this should be modified:

DocJC wrote:
Don't forget that the Xmega boots at 1 MHz

The default clock source is 2MHz internal oscillator.

Ozhan KD
Knowledge is POWER

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

Thanks JC
Nice and detailed response, thanks for that. Yes soldering is fun, the other chip on the board is the ATMega128rfa1, so same soldering issues :)

I was planning on using the onboard oscillator, so it is nice to know that it is more accurate than the ATMega.

This will serve as the brains processor for our Zigbee modules, using the ATMEGA128RFA1 to do all the comms using bitcloud.

And thanks Cliff for the link, that is very useful info.

and Ozhan, I had a look at your post on examples for the XMega, that should be made a sticky, its great.
Thanks all

_________________________________

www.proficnc.com
_________________________________
Go Aussie Go!!!

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

Any XMega boot-up at 2MHz (internal clock).
If you need a different clock, you should set it:


// ----- External Clock selection procedure!!!
  OSC_XOSCCTRL := 0x40;      //freq. range 2 - 9MHz; External Clock
  OSC_CTRL := 0x08;          //enable external oscillator
  while(XOSCRDY_bit = 0) do;

  CPU_CCP := 0xD8;           //The CCP register must be written with the correct signature
  CLK_CTRL := 3;             //
// ---------------------------------

Or, if you want to use PLL, AFTER the previous code, you can use:


  OSC_PLLCTRL := 0xC5;       //clock extern si factor 5 de multiplicare (8x5=40MHz)
//  OSC_PLLCTRL := 0x14;       //clock intern 2MHz si factor 20 de multiplicare (2x20=40MHz)
  OSC_CTRL    := 0x10;       //PLLEN enabled
  while(PLLRDY_bit = 0) do;  //wait PLL

  CPU_CCP := 0xD8;           //The CCP register must be written with the correct signature
  CLK_CTRL := 4;             //PLL