Calculating top value for atmel micro timer

Thread Starter

Link068

Joined Apr 10, 2017
31
Hi,

I am working with at90 micro and was wondering if i could ask for help on calulating top value for a given frequency.

Freq = 20khz
so Period = 50us

does the formula freq=((prescalar/timer freq)*top value) ring a bell?

the output register is on the 16 bit timer.

I know the top will work out to be 800 but my friend was telling me that you set ICR1 to 400 not 800.

Any ideas?
 

BobaMosfet

Joined Jul 1, 2009
2,211
TOP is what you're calculating, so it won't be in the equation. I would definitely use an 8 MHz crystal to give you enough master clock so that you can use a reasonable prescaler. If you're running at 1Mhz, likely you'll have to use a prescaler of 8.
 

philba

Joined Aug 17, 2017
959
Depends on your timer and micro (specific part number).

You aren't clear on what you output is. If you are trying to create a 50 uS event period then 20,000 * prescale * TOP = clock freq. You can probably do 50 uS with an 8 bit timer, btw.
 
Top