37 lines
605 B
C
37 lines
605 B
C
|
#include <avr/io.h>
|
||
|
#include "include/timer.h"
|
||
|
|
||
|
void initCtcTimer0(void)
|
||
|
{
|
||
|
/* Initialize counter 0 */
|
||
|
TCNT0 = 0;
|
||
|
|
||
|
/* Enable Counter0 Compare Match A Interrupt */
|
||
|
TIMSK0 |= (1 << OCIE0A);
|
||
|
|
||
|
/* Select clock. Prescaler of 1024 */
|
||
|
TCCR0B |= (1 << CS02) | (1 << CS00);
|
||
|
|
||
|
/* Use CTC Mode */
|
||
|
TCCR0A |= (1 << WGM01);
|
||
|
|
||
|
/*
|
||
|
* OCR0A contains TOP value for counter:
|
||
|
*/
|
||
|
OCR0A = 78;
|
||
|
}
|
||
|
|
||
|
void initOverflowTimer0(void)
|
||
|
{
|
||
|
/* Prescaler = 0 */
|
||
|
TCCR0B |= (1<<CS00);
|
||
|
|
||
|
/* Enable Timer Overflow Interrupt */
|
||
|
TIMSK0 |= (1<<TOIE0);
|
||
|
}
|
||
|
|
||
|
void initOverflowTimer1(void)
|
||
|
{
|
||
|
TCCR1B |= (1<<CS11);
|
||
|
TIMSK1 |= (1<<TOIE1);
|
||
|
}
|