Hello,
I have the following timer code, and I'd like to have it work on my shiny new ATTiny processors (I have both the ATTiny85, and ATTiny84).
I don't fully understand how timers are set up, so I ended up copy/pasting some code which worked perfectly well on the ATMega328, but isn't compiling for the ATTiny85.
The code I currently have is:
#include <avr/interrupt.h>
#include "LedMatrix.h"
// LedMatrix.h defines Display.nextScanLine() and SCAN_LINE_FREQUENCY
void startTimer() {
cli(); // disable all interrupts
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 62500/(SCAN_LINE_FREQUENCY); // compare match register.
TCCR1B |= (1 << WGM12); // CTC mode
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
sei(); // enable all interrupts
}
ISR(TIMER1_COMPA_vect) {
Display.nextScanLine();
}
The error messages I'm getting are:
LedMatrix.cpp:57: error: 'TCCR1A' was not declared in this scope
LedMatrix.cpp:58: error: 'TCCR1B' was not declared in this scope
LedMatrix.cpp:62: error: 'WGM12' was not declared in this scope
LedMatrix.cpp:64: error: 'TIMSK1' was not declared in this scope
So, it appears to me that setting up a timer isn't the same in both systems. I don't mind using #ifdef blocks to differentiate the codebase, but I'm not sure what to put into the ATTiny's block.
Any help is appreciated, including pointers to relevant documentation or tutorials.