SAM3X8E Project - Missing some #define's (?)

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

I am working with an Arduino Due development board based on the SAM3X8E, with Atmel Studio 7

 

The project I am doing utilizes the Timer Counter Driver of ASF.

 

According to the SAM3X8E documentation, there are three Timer Counter modules, with three channels each.

 

However, I only see definitions in the header files (and what gets suggested during "code completion" while typing) for what appears to be just a subset of these timer counters.  Are these header files complete?

 

 

 

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

Can you be more explicit?  Which header files?  What symbols are missing?

 

I see (sam3x8e.h):

#define TC0        ((Tc     *)0x40080000U) /**< \brief (TC0       ) Base Address */
#define TC1        ((Tc     *)0x40084000U) /**< \brief (TC1       ) Base Address */
#define TC2        ((Tc     *)0x40088000U) /**< \brief (TC2       ) Base Address */

And then you get structure definitions in tc.h, accessed via code something like:

  TC1->TC_CHANNEL[0].TC_CCR = stuf;

(This based on the CMSIS-ATMEL directories included with Arduino.  I'd guess that ASF wraps additional abstraction around things?)

 

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

Thanks for your reply, and sorry for not being more specific.

 

1. I began by using Atmel sample code for Timer Counter waveform mode provided here, in section 9.1.4:

 

http://ww1.microchip.com/downloa...

 

2. My first question is why does my project contain not just pio_sam3x8e.h (which I expect), but pio_sam3a4c.h, pio_sam3a8c.h, etc. - a total of 7 header files for the sam3x variants?  When I right-click on a symbol such as "TC0", and go to implementations, it presents all of these header files.  How do I know which one it is actually using?  For now, I assume it is the one in pio_sam3x8e.h.

 

3. The example code has the following defines:

/* Use TC Peripheral 0. */

#define TC TC0

#define TC_PERIPHERAL 0

/* Configure TC0 channel 1 as waveform output. */

#define TC_CHANNEL_WAVEFORM 1

#define ID_TC_WAVEFORM ID_TC1

#define PIN_TC_WAVEFORM PIN_TC0_TIOA1

#define PIN_TC_WAVEFORM_MUX PIN_TC0_TIOA1_MUX

 

They symbol PIN_TC0_TIOA1 is defined in arduino_due_x.h, which was also included in the project.

 

3. My MAIN question here is why do I not see similar definitions for PIN_TC1_xxx, PIN_TC2_xxx, etc.?  I am either missing some major point here (which is very possible), or this header file is incomplete.  Shouldn't there be 9 of these?

 

Note that what I am trying to do is to use several TC channels simultaneously (at least 4 channels) with  pins as outputs.

 

4. Another point of confusion I am having is the distinction between Timer Counter numbers and timer channel numbers, etc.. The naming conventions seem to be extremely ambiguous.

 

Again, I am likely missing something obvious, as I am new to Atmel Studio.

 

Thanks in advance for any help.  It is greatly appreciated!

 

 

 

 

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

I'm not sure I can explain all of this, because I don't understand it myself...

 

The first thing to understand, though, is that you're dealing with two (perhaps three) major sets of definition file.

 

First, there are the CMSIS files that define the chip and its peripherals.  CMSIS is an ARM standard thing, so there are standard ways to define various objects.  These are in ...\src\ASF\sam\utils\cmsis\ (but they aren't really part of ASF.  But: see below)

 

Second are the ASF definitions.  ASF is the Atmel Standard library, providing services and functions that are at least theoretically abstracted enough to be common across multiple chip families.  A lot of people don't like ASF very much, and I'm one of them.  It's bloated and buggy, and their idea of "abstraction" seems to be to have a common "configure_peripheralxxxx" function that uses a pointer to a structure that is chip-specific anyway (since peripherals are different across chips) :-(

 

The third set of definitions are the project-specific files like conf_board.h, conf_clocks.h, and so on.  Atmel seems to have a standard setup for these that isn't obviously awful, but also isn't very well explained.  I'm not sure that I'd call it "tightly coupled" to ASF, but it's the ASF startup code that includes and uses those definitions...

 

2. My first question is why does my project contain not just pio_sam3x8e.h (which I expect), but pio_sam3a4c.h, pio_sam3a8c.h, etc. - a total of 7 header files for the sam3x variants?  When I right-click on a symbol such as "TC0", and go to implementations, it presents all of these header files.  How do I know which one it is actually using?  For now, I assume it is the one in pio_sam3x8e.h.

Traditionally (?), the "go to implementation" features aren't quite smart enough to know about compile-time constants (like exactly which chip is in use), and I guess project creator wasn't smart enough either (or perhaps they have one example that runs on multiple boards?)  I don't know why.

 

 

3. They symbol PIN_TC0_TIOA1 is defined in arduino_due_x.h, which was also included in the project.

the arduino_due_x.h file seems to be part of their "board-level" definitions for the project.   That's swell for things like "LED_RED" and "PUSHBUTTON1", but I don't understand why generic chip-level "TIOA1 is on the TIOA1 pin of the chip" definitions are in there.

 

 

3. My MAIN question here is why do I not see similar definitions for PIN_TC1_xxx, PIN_TC2_xxx, etc.?  I am either missing some major point here (which is very possible), or this header file is incomplete.  Shouldn't there be 9 of these?

I would guess that the board-level definitions for Due are just incomplete.  Since I don't understand why they're giving stuff new names there, anyway....

 

 

4. Another point of confusion I am having is the distinction between Timer Counter numbers and timer channel numbers, etc.. The naming conventions seem to be extremely ambiguous.

I agree.  Part of the "poor abstraction" of ASF, perhaps.