ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
arduino_uno_blink_interrupt.c
1#include <avr/interrupt.h>
2#include <avr/io.h>
3#include <util/atomic.h>
4
5#include "avr/avr_timers.h"
6
7#define F_CPU 16000000UL
8// period = 1024*256*n_overflows / F_CPU
9#define n_overflows F_CPU / 1024 / 256 / 2
10
11int main(void) {
12
13 TIMER0_Init(5, 0, 1);
14
15 DDRB |= _BV(5);
16
17 sei();
18
19 while (1) {
20 }
21 return 0;
22}
23
24ISR(TIMER0_OVF_vect) {
25 static uint16_t timer_overflow_count;
26 timer_overflow_count += 1;
27 if (timer_overflow_count == n_overflows) {
28 PORTB ^= _BV(5); // flip bit
29 timer_overflow_count = 0;
30 }
31}
#define TIMER0_Init(cs, ctc, timsk0)
Initialize Timer0.
Definition avr_timers.h:28