Where are the definition for some of the functions?

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

Xmega seems like they really want user to memorize a lot of function name (at least that's what it seems like to me), this actually drives me nuts. I don't know where are all these functions are located, can someone direct me to the location where it contains all these mysterious functions that sets particular registers?

Some examples are like:

TC_SetPeriod(&TCC0, 0xFFFF);
TC_SetCompareA( &TCC0, 0x0300);

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

Aren't these in the AVR app notes - there's a whole series from AVR1000 onwards for Xmega. The same code is the basis of ASF which I presume you know about?

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

Thanks Clawson. I know there are App notes from avr1000 onward, I've downloaded and pretty much all the one involved with xmega. But the problem for me is I want to see how it is being defined first. Maybe here is a different question, but where is the #include location? I've checked the winavr and i don't think I find the file, which is used by xmega devices anywhere, anyone can give me a pointer?

BTW, what is ASF?

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

Quote:

I've checked the winavr

That's because those functions are nothing to do with AVR-LibC within WinAVR. As I say they come from Atmel so you need to look to their source code. They are either in ASF (AVR Software Framework) or they are in the code that accompanies the app notes. ASF has a whole forum here, it's also now part of what makes AS5 so big and bloaty.

EDIT a quick Google tells me that these functions are located in TC_driver.h which is part of the software that accompanies application note AVR1306. So go to this page (for example):

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

and where it says "AVR1306" you will see a PDF icon and a disk icon. Click the PDF icon to download the explanatory text and the disk icon to get the software.

Within the .zip you will find the TC_driver.h and within that:

#define TC_SetPeriod( _tc, _period ) ( (_tc)->PER = (_period) )

So this looks to be one of those pointless macros that is just being used to obfuscate code and it's further annoying in that it's a macro with a name that isn't all upper-case (which would have given a clue as to it being a macro).

TC_SetCompareA is the equally under-whelming:

#define TC_SetCompareA( _tc, _compareValue ) ( (_tc)->CCABUF = (_compareValue) )

The two lines you quoted are therefore:

(&TCC0)->PER = 0xFFFF;
(&TCC0)->CCABUF = 0x300;

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

They are very underwhelming indeed.

Thanks, i was using that file all day and only looking for the .c file and i didn't even bother to look into the .h file. Thanks, Clawson!

I was thinking they are some obscure code that i couldn't access. :roll:

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

Quote:

i didn't even bother to look into the .h file.

I'll bet if those "functions" had been in upper-case the .h would have been the first place you looked!

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

clawson wrote:
Quote:

i didn't even bother to look into the .h file.

I'll bet if those "functions" had been in upper-case the .h would have been the first place you looked!

Well, i wouldn't say it's the "first" place, but it'd definitely increase the likelyhood by a huge margin!