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
avr_timers.h
Go to the documentation of this file.
1#ifndef AVR_TIMERS_H
2#define AVR_TIMERS_H
3
4/** \file */
5
6#include <avr/io.h>
7#include <stdint.h>
8
9/** \brief Initialize Timer0
10 *
11 * Normal waveform gen mode (WGM2:1 are 0)
12 *
13 * \param cs 3 bits: 0: no timer, 1: no prescale, 2, /8 prescale
14 * 3: /64 prescale 4: /256 prescale 5: /1024 prescale
15 *
16 * \param ctc (1 bit); 1: clear counter when counter reaches OCR0A;
17 * 0: clear counter when read 255
18 *
19 * \param timsk0: bits enable interrupts:
20 * bit 0: interrup on overflow
21 * bit 1: interrupt on match OCR0A
22 * bit 2: interrupt on match OCR0B
23 *
24 * OCR0A and OCR0B are writable compare registers to set when
25 * interrupt and ctc happens
26 *
27 */
28#define TIMER0_Init(cs, ctc, timsk0) \
29 TCCR0A = ((ctc & 1) << WGM01); \
30 TCCR0B = cs & 0b111; \
31 TIMSK0 = timsk0 & 0b111;
32
33#endif