[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-chat] Help! Can't get Timer 3 interrupt to work (mega128)
From: |
Rick Mann |
Subject: |
[avr-chat] Help! Can't get Timer 3 interrupt to work (mega128) |
Date: |
Sat, 4 Mar 2006 16:23:11 -0800 |
I have the following code (sorry for the bad formatting; I use 4-char
tab stops):
void
initControl()
{
// Set up Timer 3. It should count, and generate an interrupt at
TOP.
// This will drive the basic control loop.
TCCR3A = (0 << COM3A1) | (0 << COM3A0) // Output
disconnected (we only want interrupts)
| (0 << COM3B1) | (0 << COM3B0) // Output disconnected (we
only want interrupts)
| (0 << COM3C1) | (0 << COM3C0) // Output disconnected (we
only want interrupts)
| (0 << WGM31) | (0 << WGM30);
// CTC, TOP := ICR3
TCCR3B = (0 << ICNC3) | (0 << ICES3) // Disable input
capture noise canceler, edge select to negative.
| (0 << WGM33) | (1 << WGM32)
// CTC, TOP := OCR3A
| (0 << CS32) | (1 << CS31) | (0 << CS30); // prescale: clk(i/
o) / 8
OCR3A = 9999;
// 100 Hz loop
//ICR3 = 1999;
// 500 Hz loop
//ICR3 = 999;
// 1000 Hz
loop
//ICR3 = 499;
// 2000 Hz
loop
TCNT3 = 0;
// Reset
the timer
TIMSK |= (1 << OCIE3A); // Enable Timer 3 OCRA match
interrupt
}
It's supposed to call the interrupt handler at 100 Hz. Instead, the
default handler is getting called at 10 kHz. I've put in handles for
all of the TIMER3 vectors I could find in iom128.h, but it's still
triggering something else. Any ideas?
I was hoping to use the timer in CTC mode, with no output pins
active, to generate an internal interrupt.
Any ideas what I'm doing wrong? I guess my next step is to install
handlers for all the rest of the vectors...sigh.
Thanks!
--
Rick
smime.p7s
Description: S/MIME cryptographic signature
- [avr-chat] Help! Can't get Timer 3 interrupt to work (mega128),
Rick Mann <=