Hi, I'm a total newb. I've read many tutorials though and am trying to get a stupid LED to blink on the ATTiny25 using a CTC interrupt. (I used the TIMER0_COMPB vector rather than pure CTC mode, because I want to add a delay in the beginning and do some other stuff than just blinking at one frequency later). I modified the code in the AVR timers tutorial to supposedly match the registers and bits required for the 25 versus the mega the tutorial was written for. (I also added a sleep mode between interrupts). It's still not working though. I have no clue what's wrong. I've been over and over the datasheet. Can someone tell me what is wrong with this?
// Flash LED's - A program to flash an LED at 4 Hz on the ATTiny25V // by interrupting on timer compare CTC mode. #include#include #include int main (void) { ACSR |= (1 << ACD); // Turn off Analog comparator to save power DDRB |= (1 << 0); // Set LED as output TCCR0A |= (1 << WGM01); // Configure timer 1 for CTC mode TIMSK |= (1 << OCIE0B); // Enable CTC interrupt sei(); // Enable global interrupts OCR0B = 244; // Set CTC compare value to 4 Hz at 1 MHz AVR clock, with a prescaler of 1024 (976.6 Hz) TCCR0B |= ((1 << CS02) | (1 << CS00)); // Start timer at Fcpu/1024 MCUCR |= (1 << SE); // Enable sleep mode (hopefully) set_sleep_mode(SLEEP_MODE_IDLE); for (;;) { sleep_mode(); //Sleep between interrupts (hopefully) } } ISR(TIMER0_COMPB_vect) { PORTB ^= (1 << 0); // Toggle the LED }