Pages: [1]   Go Down
Author Topic: Syncing Timer1 and Timer2  (Read 380 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, I'm using all three timers on the arduino and I've successfully synced timer0 and timer1.  I basically 'eyeballed' the syncing by dimming two l.e.d. lights and checking to make sure they were dimming at the same rate.  like i said, timer0 and timer1 are synced.  Now I'm trying to sync timer2 to the other two timers and i'm not getting the results i want.  I know that timer2 uses milliseconds as opposed to microseconds, like the first 2.  I've tried dividing by a 1000 to convert millis to micros but its not working.  Does anyone know how to get timer 2 counting in microseconds instead of milliseconds?

thanks yall


Offline Offline
Faraday Member
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The datasheet contains everything you might want to learn about timers:

Have a look at  16.1.1 and 17.11.9 "GTCCR"

So I would try

// stop prescalers
GTCCR = 1 << TSM;
GTCCR = 1 << TSM | 1 << PSRASY | 1 << PSRSYNC;

ensure here that all timers have matching prescalers and settings

// go
GTCCR = 0;

Check out my experiments

Pages: [1]   Go Up
Jump to: