Functions

timer.c File Reference

#include <avr/power.h>
#include "timer.h"

Functions

void timer1_init (void)
 initialize timer1

Detailed Description


Function Documentation

void timer1_init ( void   ) 

initialize timer1

Set up timer1 for continous counting.

The prescaler is set to 1/256. Therefore the elapsed time t can be calculated in the following way: $t = (TCNT1(T_2) - TCNT1(T_1)) * 256 / F_{CPU}$

{
  power_timer1_enable ();
  TCCR1A = 0;
  TCCR1B = _BV(CS12); /* prescaler 1/256 */
  TIMSK1 = 0; /* no INT generation */
}