I'm looked around the datasheet and sample code and I've come up with the following as my solution to making an LED flash (The timing isn't important at the moment, I just want to make an interrupt that fires when the timer overflows.) The controller I'm using is the atmega328P.
#include <avr/interrupt.h>
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
TCCR0A=0x00; // Normal Timer0 Operation
TCCR0B=0b00000001; // Prescaler and clock select
TCNT0=0x00; // Start count from here
TIMSK0=(1<<TOIE0); // Enable Counter Overflow Interrupt
digitalWrite(ledPin, HIGH);
sei();
TIFR0=0b00000000;
}
ISR(TIM0_OVF)
{
digitalWrite(13, LOW);
TCNT0=0;
while(1);
}
void loop()
{
}
So far, theres no luck in making the LED turn off from its initial lit state. I've tried to manually set the TOV0 bit to 0 and 1 to try to see if we're allowed to do that...but it didn't work.
For the ISR handler I've tried TIM0_OVF_vect and TIM0_OVF since I've seen both used but neither works.
Any ideas on how to work this? I've read about some library functions that may make interrupt usage easier but I want to do this by at this lower level.