XMEGA 16-bit register write difference

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

For those who are starting to write XMEGA A programs, here's a warning -- there's a difference in writing 16-bit registers in XMEGA A vs. AVR: XMEGA A requires the low byte to be written first whereas the AVR requires the high byte to be written first. For those like myself who have cross-MCU / cross-compiler compatibility macros and are using XMEGA A's, it's time to modify them for 16-bit register write access on XMEGA A.

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

Thanks for the 'head up', Kevin. I had received my two samples yesterday...

Have fun.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Hmmm--there has been discussion on the compiler boards since WAAYY back on the merits and demerits of having the compiler do "frog = TCNT1;" and "TCNT1 = frog;" when TCNT1H/L are out of I/O space. Especially when the access is "hidden" via a pointer access. And consider the case where someone gets "tricky" in a tight piece of code and only read or wrote the "safe" half.

CodeVision handled the "general" case by doing code generation for 16-bit reads & writes in the "proper" AVR order as a matter of course which covered all but the tricky cases.

So I suppose that will have to change for Xmega targets for writes. That will be a good thing to check when I get my samples and try some programs.

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.

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

All good points, Lee. For myself, I've moved away from compiler generated 16-bit access to writing 8-bit access to multi-byte registers. Both approaches have merits.