My interrupt code will not compile without errors:
/*
Interrupt Test Program
- 2/24/2025
Author: Terry Benson
*/
// Arduino NANO 33 IoT board selected
#include "SAMDTimerInterrupt.h" // This has no affect on the errors
bool ledOn = false;
const unsigned long TIME_TICKS = 7500; // for 10 ms interrupts at 48 MHz
const bool PRESCALER = B00000011; // Prescaler of 64
const bool ENABLE_ISR = B00000010; // Enable the ISR to generate an interrupt
// ISR for the switch debounce functions using timer 1
ISR (TIMER1_COMPA_vect)
{
ledOn = !ledOn; // toggle led
if (ledOn) {
digitalWrite(LED_BUILTIN, HIGH);
} else {
digitalWrite(LED_BUILTIN, LOW);
}
} // End of ISR
void setup()
{
// flash the LED at the interrupt rate
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
ledOn = false;
// Set up timer for 10 ms interrupts
TCCR1A = 0; // Init Timer1A
TCCR1B = 0; // Init Timer1B
TCCR1B |= PRESCALER; // Set Prescaler
OCR1A = TIME_TICKS; // Timer Compare1A Register
TIMSK1 |= ENABLE_ISR; // Enable Timer COMPA Interrupt
}
void loop()
{
// set up main function here
}
I get these errors among others (with or without the Included library):
TimerISR_Test\TimerISR_Test.ino:16:5: error: expected constructor, destructor, or type conversion before '(' token
ISR (TIMER1_COMPA_vect)
^
TimerISR_Test\TimerISR_Test.ino:34:3: error: 'TCCR1A' was not declared in this scope
TCCR1A = 0; // Init Timer1A
^~~~~~
Do I need to use different names for the Timer Registers?