How to make Atmega328 timmer interrupt tick every 1 second?
问题 I've an Atmega328p and I've connected an LED to it's D4 pin and I want it to turn LED on/off every one second. I found this tutorial and I've change it base on some online AVR timmer calculator and the 12MHZ external crystal which I've used, to this : #define F_CPU 12000000UL #include <avr/io.h> #include <avr/interrupt.h> int main(void) { DDRD |= 1 << 4; PORTD |= 1 << 4; ICR1 = 0xB71B; TCCR1B |= (1 << WGM12); // Mode 4, CTC on OCR1A TIMSK1 |= (1 << ICIE1); //Set interrupt on compare match