xmega compiling (not flashing yet)
This commit is contained in:
parent
5836d1a06a
commit
6b58b0c7dd
11 changed files with 152 additions and 2 deletions
|
@ -43,6 +43,7 @@ void timer_init(void)
|
|||
# error "Timer prescaler value is NOT vaild."
|
||||
#endif
|
||||
|
||||
#ifndef __AVR_XMEGA__
|
||||
#ifndef __AVR_ATmega32A__
|
||||
// Timer0 CTC mode
|
||||
TCCR0A = 0x02;
|
||||
|
@ -58,6 +59,13 @@ void timer_init(void)
|
|||
OCR0 = TIMER_RAW_TOP;
|
||||
TIMSK = (1 << OCIE0);
|
||||
#endif
|
||||
#else
|
||||
TCC0.CTRLE = 0x01; // set timer in 8bit mode (default is 16 bits)
|
||||
TCC0.INTCTRLA = 0x02; // Interrupt Enable register A (enable INT for tc0 (medium level))
|
||||
TCC0.PER = 132; // set period to 228 khz
|
||||
TCC0.PERBUF = 132; // buffer for writing to TCC0.PER.
|
||||
TCC0.CTRLA = prescaler; // clk=30324000 H
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -117,11 +125,15 @@ uint32_t timer_elapsed32(uint32_t last)
|
|||
}
|
||||
|
||||
// excecuted once per 1ms.(excess for just timer count?)
|
||||
#ifndef __AVR_XMEGA__
|
||||
#ifndef __AVR_ATmega32A__
|
||||
#define TIMER_INTERRUPT_VECTOR TIMER0_COMPA_vect
|
||||
#else
|
||||
#define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect
|
||||
#endif
|
||||
#else
|
||||
#define TIMER_INTERRUPT_VECTOR TCE0_OVF_vect
|
||||
#endif
|
||||
ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK)
|
||||
{
|
||||
timer_count++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue