Typedefs | Functions

timer.h File Reference

functions for time measurement More...

#include <avr/io.h>

Go to the source code of this file.


typedef uint16_t timerval_t
 type for timer value


void timer1_init (void)
 initialize timer1
void timer1_func_start (timerval_t *tv)
 store current timer val into variable
uint16_t timer1_func_end (timerval_t *tv)
 get elapsed time since timer1_func_start()

Detailed Description

functions for time measurement

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 */