Go Down

Topic: atmel 168 timer and prescaler question (Read 682 times) previous topic - next topic

johnm1019

Feb 06, 2008, 08:25 am Last Edit: Feb 06, 2008, 08:29 am by johnm1019 Reason: 1
So I've setup an ISR using Timer 1.

What I can't seem to get is right is the physical amount of time per count.

I've tried all sorts of prescalers, using the CS10,11, and 12 bits.

Those are divisions of the I/O-clk, and i can't find anywhere for the atmel 168 what that clock is.

I've setup CTC, but it still seems that I need to reset TNT1 = 1 and OCR1A = num_max_counts after every ISR loop or the behavior is different

I'm setting my TMR1A = 0x00 and my TMR1B = (1 << CS10)  [or 11 or 12 as i play with prescalers]

Any help here or example scripts would be appreciated that show for a given timer setup exactly how much time passes for each count.  I'm doing some numerical integration and its vital i get this.


FWIW i'm taking care of the analogRead outside the interrupt, and my main loop() function has no delay statements.  I am running a serial connection at 9600 baud.


Thanks!
JM

mem

try setting  TCCR1A for normal counting mode :
TCCR1A = 0x00;      // COM1A1=0, COM1A0=0 => Disconnect Pin OC1, => PWM Operation disabled

setting cs11 sets the prescaller to divide the arduino's 16mhz clock by 8  
 TCCR1B = 0x02;      // TCNT1 increments every .5 uS  

once you have that running you can play with the output compare register values.

I hope that helps.

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