[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] cannot access TCC0.PER or any other 16-bit register on AT
From: |
Stefan Schoenleitner |
Subject: |
[avr-libc-dev] cannot access TCC0.PER or any other 16-bit register on ATXMega128A1 |
Date: |
Sun, 18 Sep 2011 13:54:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 |
Hi,
I'm trying to set up a timer on an ATXMega128A1 using avr-gcc 4.3.4
and avr-libc 1:1.6.7-1ubuntu2.
In my code I have the following:
------------------------------
#include <avr/io.h>
.....
TCC0.CTRLD = TC_EVACT_QDEC_gc | TC_EVSEL_CH0_gc;
TCC0.PER = 1000;
TCC0.CTRLA = TC_CLKSEL_DIV1_gc;
------------------------------
However, when compiling I get the following error:
------------------------------
$ avr-gcc -Os -gstabs -std=c99 -funsigned-char -funsigned-bitfields
-fpack-struct -fshort-enums -Wall -Wstrict-prototypes -pedantic
-mmcu=atxmega128a1 -c -o main.o main.c
main.c: In function ‘main’:
main.c:130: error: ‘TC0_t’ has no member named ‘PER’
make: *** [main.o] Error 1
------------------------------
I had a closer look at avr/iox128a1.h and saw that in contrast to
the compiler error, there is a PER register defined:
------------------------------
#define TCC0 (*(TC0_t *) 0x0800) /* Timer/Counter C0 */
...
#define TCC0_PER _SFR_MEM16(0x0826)
....
typedef struct TC0_struct
{
register8_t CTRLA; /* Control Register A */
...
_WORDREGISTER(PER); /* Period */
...
} TC0_t;
------------------------------
Since "PER" is definitely in the struct, I'm really wondering why I get the
compiler error above.
I suppose this is a bug.
A workaround is to use TCC0_PER to directly access the register.
cheers,
Stefan
- [avr-libc-dev] cannot access TCC0.PER or any other 16-bit register on ATXMega128A1,
Stefan Schoenleitner <=