Xmega32A4 /16 bit timer / ICCAVR

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

I am trying to test Xmega's timer counter using ICCAVR complier, but having a problem in entering value to PER register.
My code is:
TCC0.PER=0x00ff.
ICCAVR returns error that "operands of = have illegal types 'union union16b_TC_PER' and 'int'.
Does anyone know about what the problem is?

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

TCC1.PER=0x00FF; //semicolon at end of line

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

Hi, Thank you very much for your advice. Actually, I had written TCC0.PER=0x00ff; like your suggestion, and got that result. Thank you.

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

Hi masaavr,

I had exactly the same problem, asked Richard, hi kindly ignored the question :wink: but found the time to acknowledge my success in solving the problem.
After some desparate digging I found out that the access to the 16-bit registers has a form: base.structmember.i
Your statement should be TCC0.PER.i=0x00FF;
In addition at the begining of your file:
#define _ansi_unions_in_ior_structs
before
#include

I was dissapointed that this was not more explicit in the include files, so people not specialising in C coding, like me, could be spared the time waste.

Regards,
Jan

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

Thank you very much for your advice. I just tried it and worked! Thank you.