ATiny1614 'TCA0_SINGLE.INTFLAGS' Undeclared Compiler error

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

Hello,

In Atmel Studio7 with an Attiny 1614 project, i have found that this:

TCA0_SINGLE.INTFLAGS 

is not recognized as being declared.

 

When changed to using underscores, there is no compiler error.

TCA0_SINGLE_INTFLAGS

The Attiny1614 header file shows

typedef struct TCA_SINGLE_struct
{
    register8_t CTRLA;  /* Control A */
    register8_t CTRLB;  /* Control B */
    register8_t CTRLC;  /* Control C */
    register8_t CTRLD;  /* Control D */
    register8_t CTRLECLR;  /* Control E Clear */
    register8_t CTRLESET;  /* Control E Set */
    register8_t CTRLFCLR;  /* Control F Clear */
    register8_t CTRLFSET;  /* Control F Set */
    register8_t reserved_0x08;
    register8_t EVCTRL;  /* Event Control */
    register8_t INTCTRL;  /* Interrupt Control */
    register8_t INTFLAGS;  

//////AND/// 

/* TCA_SINGLE.INTCTRL  bit masks and bit positions */
#define TCA_SINGLE_OVF_bm  0x01  /* Overflow Interrupt bit mask. */
#define TCA_SINGLE_OVF_bp  0  /* Overflow Interrupt bit position. */
#define TCA_SINGLE_CMP0_bm  0x10  /* Compare 0 Interrupt bit mask. */
#define TCA_SINGLE_CMP0_bp  4  /* Compare 0 Interrupt bit position. */
#define TCA_SINGLE_CMP1_bm  0x20  /* Compare 1 Interrupt bit mask. */
#define TCA_SINGLE_CMP1_bp  5  /* Compare 1 Interrupt bit position. */
#define TCA_SINGLE_CMP2_bm  0x40  /* Compare 2 Interrupt bit mask. */
#define TCA_SINGLE_CMP2_bp  6  /* Compare 2 Interrupt bit position. */

/* TCA_SINGLE.INTFLAGS  bit masks and bit positions */
/* TCA_SINGLE_OVF  is already defined. */
/* TCA_SINGLE_CMP0  is already defined. */
/* TCA_SINGLE_CMP1  is already defined. */
/* TCA_SINGLE_CMP2  is already defined. */

Other parts of my code with using periods '.' instead of underscores '_' in the register names appear to be recognized just fine.

 

    /* TCA0 used for button pressing, led control and 20 minutes on timer. Clk/1024*/
    TCA0_SINGLE.CTRLA |= TCA_SINGLE_CLKSEL_gm;//TCA0 cpu-clk divide by 1024. 7812.5hz counter
    TCA0_SINGLE.CTRLA |= TCA_SINGLE_ENABLE_bm;// Timer/Counter A is enabled by (1<<0)
    TCA0_SINGLE.CMP2 = FIVE_MS;// Every 5ms(200hz) button scanning (manual flag check)
    TCA0_SINGLE.CMP0 = 256;// Slow counter @ 30.5hz

    ////
    /* TCB0-1 used in 16bit no-prescale counter(8mhz), default Periodic update mode */
    TCB0.CTRLA |= TCB_ENABLE_bm;// Timer counter B0-1 enabled.
    TCB1.CTRLA |= TCB_ENABLE_bm;//
    TCB0.CCMP  |= 2841;// 11Mhz 8bit dac clock count compare match
    TCB1.CCMP  |= 2373;// 13.17hz
    TCB0.INTCTRL |= TCB_CAPT_bm;//Interrupts enabled
    TCB1.INTCTRL |= TCB_CAPT_bm;

For now ill just use underscores even though i do like:

TCB0.CTRLA /*vs*/ TCB0_CTRLA

For registry names to stand out from registry bits.

This topic has a solution.

~William

Last Edited: Fri. Jun 15, 2018 - 05:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is not it a typo?
There is one definition concatenated with underscores, and if you use what is defined as a structure it is all periods.

 

I am using it for the period.

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Suggest you look again at the header file:

#define TCA0                  (*(TCA_t *) 0x0A00) /* 16-bit Timer/Counter Type A */

So the base of the timer object is "TCA0". Then there is

/* 16-bit Timer/Counter Type A */
typedef union TCA_union
{
    TCA_SINGLE_t SINGLE;  /* 16-bit Timer/Counter Type A - Single Mode */
    TCA_SPLIT_t SPLIT;  /* 16-bit Timer/Counter Type A - Split Mode */
} TCA_t;

and finally the

/* 16-bit Timer/Counter Type A - Single Mode */
typedef struct TCA_SINGLE_struct
{
    register8_t CTRLA;  /* Control A */
    register8_t CTRLB;  /* Control B */
    register8_t CTRLC;  /* Control C */
    register8_t CTRLD;  /* Control D */
    register8_t CTRLECLR;  /* Control E Clear */
    register8_t CTRLESET;  /* Control E Set */
    register8_t CTRLFCLR;  /* Control F Clear */
    register8_t CTRLFSET;  /* Control F Set */
    register8_t reserved_0x08;
    register8_t EVCTRL;  /* Event Control */
    register8_t INTCTRL;  /* Interrupt Control */
    register8_t INTFLAGS;  /* Interrupt Flags */
    register8_t reserved_0x0C;
    ...
} TCA_SINGLE_t;    

that you already found. Putting that all together gives you:

TCA0.SINGLE.INTFLAGS

You are attempting to use:

TCA0_SINGLE.INTFLAGS 
    !

So you have an underscore where there should be a dot.

Last Edited: Fri. Jun 15, 2018 - 04:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

/* 16-bit Timer/Counter Type A */
typedef union TCA_union
{
    TCA_SINGLE_t SINGLE;  /* 16-bit Timer/Counter Type A - Single Mode */
    TCA_SPLIT_t SPLIT;  /* 16-bit Timer/Counter Type A - Split Mode */
} TCA_t;

I need to keep up training in C' programming,iv never used union befor.

And i just went ahead and thought the registry naming would be the same.

Think i will use 'dots'/periods from now on for all the registries.

~William

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

kabasan wrote:

Along with Clawsons correction and seeing your way, I now see how period spacing in the way to go for the registers.

~William

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

It's not like you get a choice. These are compound data structures and each level of name MUST be separated by '.'
.
It's true that Atmel did spoil users in the original Xmega headers in that they also #defined PERIPHERAL_REGISTER symbols alongside PERIPHERAL.REGISTER names so that there were symbols the assembler could use as well as C/C++ (assembler doesn't understand the concepts of struct/union/etc) but they seem to be making C only headers now for devices such as this.