heya dottore11,
The alfredstate.edu link above has helped me decode much of the information about Timer1 and makes a great supplement to the datasheet. Also, the
Timer1 library is a great wrapper for accessing features of the timer.
To slow down the speed of the timer you can use the setPeriod(long microseconds) method. The value passed to setPeriod should be at least twice the max delay between two events (pin changes or whatever you are measuring). The Timer1 lib causes the timer to count up then down, if you read the timer value on the down stroke then it will give you erroneous results.
I'm not sure what you mean as to "using this timer1 as a global timer". The timer is global in the sence that it's variables (aka registers) have global scope. It's all about how you set up the timer for your use.
The actual count for timer1 is available by reading TCNT1. There are functions in the Timer1 lib that start, stop and reset the counter. The value in TCNT1 is in ticks of the timer, from 0-65536. To get this into microseconds you first multiply by the prescaler value (x1, x8, x64, x265, or x1024) to get the total number of clock cycles this represents, then divide by the number of clock cycles a microsecond, (F_CPU / 1000000). There are a couple of handy macros defined by wiring.h here:
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
Also, heres a little snippet of code that I use to read timer1's value in microsecs:
ulong readTimer1() //returns the value of the timer in microseconds
{ //rember! phase and freq correct mode counts up to then down again
switch (Timer1.clockSelectBits)
{
case 1:// no prescalse
return ((TCNT1 * 1000L) / (F_CPU / 1000L));
break;
case 2:// x8 prescale
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<3;
break;
case 3:// x64
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<6;
break;
case 4:// x256
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<8;
break;
case 5:// x1024
return ((TCNT1 * 1000L) / (F_CPU / 1000L))<<10;
break;
default:
return 0;
}
}