#include <stdint.h>
#define U_DDRB ((volatile uint8_t*)0x24)
#define U_PORTB ((volatile uint8_t*)0x25)
#define U_TCCR1A ((volatile uint8_t*)0x80)
#define U_TCCR1B ((volatile uint8_t*)0x81)
#define U_OCR1AH ((volatile uint8_t*)0x89)
#define U_OCR1AL ((volatile uint8_t*)0x88)
#define U_TIMSK1 ((volatile uint8_t*)0x6F)
#define U_SREG ((volatile uint8_t*)0x5F)
// Correct ISR vector for TIMER1 COMPA is __vector_17 (per datasheet + 0-indexed vector table)
void __vector_17(void) __attribute__((signal, used));
void __vector_17(void) {
*U_PORTB ^= (1 << 7); // Toggle PB7
}
int main(void) {
*U_DDRB |= (1 << 7); // Set PB7 as output
*U_PORTB &= ~(1 << 7); // Ensure LED is initially OFF
*U_TCCR1A = 0x00; // Normal port operation
*U_TCCR1B = (1 << 3); // WGM12 = 1 (CTC mode)
*U_TCCR1B |= (1 << 2) | (1 << 0); // Prescaler = 1024
// Set OCR1A = 15625 for 1-second interval
*U_OCR1AH = (15625 >> 8);
*U_OCR1AL = (15625 & 0xFF);
*U_TIMSK1 |= (1 << 1); // Enable Timer1 COMPA interrupt (OCIE1A)
*U_SREG |= (1 << 7); // Enable global interrupts (I-bit)
while (1); // wait for ISR
}