xmega dedicated naming conventions

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

For the XMEGA, Atmel devised some standard naming conventions for registers, bit names, bit group masks, etc. I found it tedious at first, but am trying to get used to using the standard names. Every now and then, though, I encounter one that doesn't work and I can't guess at the correct name.

Is there a list somewhere?

Related question...the include file defining these standard names.

AVR1000: Getting Started Writing C-code for XMEGA says:

Quote:
A dedicated header file is available for each XMEGA device. If the target device is specified in the project settings (assuming that one uses the IDE for IAR EWAVR), the IAR compiler will automatically include the correct header file if the device file is included as shown in Code Listing 3-1.
Quote:
Code Listing 3-1. IAR header file inclusion.
#include

That #include doesn't work for me in avr-gcc. I've seen code snippets that, for example,
#include "iox32a4.h"
but this frequenctly results in conflicts for me.

What is the best practice here? (I have tried to find the answer in the getting started tuts here, but failed.)

I'm sorry if I double posted. Forgot the subject line the firt time.

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

I use a Xmega128a1 and look up the names in:

iox128a1.h

after a while you will get used to it.

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

The right file to include is

#include 

Just like for every other AVR.

The naming conventions are mostly documented in the very app note you referenced to, AVR1000. They are

_bp - Bit position
_bm - Bitmask _bm = (1 << _bp)

_gp - Bit group position 
_gm - Bit group mask _gm = (1 << _gp)

_gc - Bit group configuration mask

Stealing Proteus doesn't make you an engineer.

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

Quote:
The right file to include is

#include  

Just like for every other AVR.

I thought that'd be good enough, too, but then I encounter errors when I use exact names from atmel's own app notes. Either the app note folks errored or I was missing something. Being new to avr, I decided upon the latter.

Quote:
The naming conventions are mostly documented in the very app note you referenced to, AVR1000. They are

_bp - Bit position 
_bm - Bitmask _bm = (1 << _bp) 

_gp - Bit group position 
_gm - Bit group mask _gm = (1 << _gp) 

_gc - Bit group configuration mask

That's the easy part for me. Is the rest of it, for example, SYSCLCK_, SYS_CLCK_, SYS_CLK_SYSTCLCK_, SYS_CLOK_, or SYS_@#$%^_?

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

Quote:

The right file to include is

#include  

Just like for every other AVR.


Just to add to that. The actual model the code is built for is then determined by a -mmcu= switch that is passed to the compiler. This then defines a model specific label within the compiler that is used within to select one specific .h file for the model that is being used. In this case it is:

#elif defined (__AVR_ATxmega32A4__)
#  include 

that is used as the internal defined label will be __AVR_ATxmega32A4__

So the file that's actually used when you build for this model is:

\winavr\avr\include\avr\iox32a4.h

It's quite possible for you to look at this in an editor to check a specific register or bit name.

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

steverino wrote:
That's the easy part for me.
Quote:
Sorry for wasting my time to explain the obvious.
Is the rest of it, for example, SYSCLCK_, SYS_CLCK_, SYS_CLK_SYSTCLCK_, SYS_CLOK_, or SYS_@#$%^_?
Chapter 31 in the A manual.

Stealing Proteus doesn't make you an engineer.

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

Quote:
It's quite possible for you to look at this in an editor to check a specific register or bit name.

You're right. I have been using the A manual which can get me close. It is large and unwieldy and I was hoping for a more concise source. Perhaps I will distill the include file a bit.

Thanks, and thanks for the in depth explanation as well.

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

ArnoldB wrote:
Chapter 31 in the A manual.
What is the A manual?

Iluvatar is the better part of Valar.

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

Michael,

For Xmega, rather than doing a huge copy/paste exercise (often with errors!) to copy similar details between many separate model datasheets, Atmel have now chosen to make a generic "family" manual and then a much smaller "device specific" datasheet for each device. So if you look at a page such as the ATxmega128A1:

http://www.atmel.com/dyn/product...

you see two datasheets listed - one is ATxmega64A1/128A1/192A1/256A1/384A1 specific (106 pages) and the other covers all "A" devices (A1, A4) and is 445 pages. That is the "A manual".

This is just one of many niggles I have with Xmega. I know the copy/paste technique often introduced small errors in the tiny/mega data and there's probably a lot of repetition. But if you were programming a mega16 you just downloaded one "mega16 datasheet" and it contained everything you could hope to know about the chip in a single, Ctrl-F searchable document. Now that info is split, Murphy (or Sod or someone)'s Law states that it's ALWAYS the wrong .PDF you go looking for some detail in.

Cliff

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

skeeve wrote:
ArnoldB wrote:
Chapter 31 in the A manual.
What is the A manual?
The Atmel document called "XMEGA A MANUAL".

Stealing Proteus doesn't make you an engineer.

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

ArnoldB wrote:
skeeve wrote:
ArnoldB wrote:
Chapter 31 in the A manual.
What is the A manual?
The Atmel document called "XMEGA A MANUAL".
Ah.
Putting XMEGA in got me some hits.

Iluvatar is the better part of Valar.

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

Quote:

That's the easy part for me. Is the rest of it, for example, SYSCLCK_, SYS_CLCK_, SYS_CLK_SYSTCLCK_, SYS_CLOK_, or SYS_@#$%^_?

"The difference between a S_EXCHANGE and a SEX_CHANGE is well placed underscore." -- Intel 8048 User Manual circa 1977.

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

Quote:

That's the easy part for me. Is the rest of it, for example, SYSCLCK_, SYS_CLCK_, SYS_CLK_SYSTCLCK_, SYS_CLOK_, or SYS_@#$%^_?

Whether Xmega, or similar expeditions as being described here, I let the computer do the walking. Brute-force searches of all the files in the "include" directory for example. Once you get a few pertinent hits those file(s) are now open in the editor and can nearly instantly be searched for fragments.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.