Go Down

Topic: Syncing Timer1 and Timer2 (Read 440 times) previous topic - next topic

HiTekRMD

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



Udo Klein

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

http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf

Have a look at  16.1.1 and 17.11.9 "GTCCR"

So I would try

Code: [Select]

// 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 http://blog.blinkenlight.net

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy