Display_Avr_3/UART/timer.c
Kirill Kurshakow 0a9eb215db uart modified
2023-11-07 12:01:09 +03:00

23 lines
355 B
C

#include <avr/io.h>
#include <avr/interrupt.h>
static volatile unsigned long timerMillis = 0;
void timerInit() {
TCCR1B |= (1 << WGM12) | (1 << CS11) | (1 << CS10);
OCR1A = 249;
TIMSK1 |= (1 << OCIE1A);
sei();
}
unsigned long millis() {
unsigned long ms;
cli();
ms = timerMillis;
sei();
return ms;
}
ISR(TIMER1_COMPA_vect) {
timerMillis++;
}