Newbie & Timer prescaler

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a point of clarification.

I assume that with an 8 bit timer on a 2313 at 4Mhz with the prescaler set at one I would trigger a timer interrupt at 4000000/256 (every 64 microseconds) and that at a prescale of 8 it would be calulated as 4000000/(256*8) - every 512 microseconds. Is that correct?

With a 16 bit timer the math would be 4000000/65536 (every 16msecs) and so on... True?

If not, please explain how the prescaling works and how to calculate timer interrupts.

Thanks,

Marc Brule

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

You seem to have it under control. FYI, have you seen or used AVRCalc. It calculates various register values depending on the time delay or frequency or baud rate you are interested in. It is available here in the tools section. Go up to the upper left of this screen and type in AVRCalc in the Search window. It is a very useful tool in my opinion.

Regards,
Steve

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The spec sheet defines the relationship between the prescale bits and the actual prescale value.

Jim Wagner

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I haven't run through the numbers you presented, but a couple of points:

--You don't HAVE to have a timer run through all the 8 or 16 bit values. You can preload the timer to a value for a shorter interval. [And on AVRs with output compare, this process can be "automated" by having the count clear at compare match.]

--Search this site [not just the Forum] using the slot at the top left of the page for "AVRCalc" and download the utility. It is very good to understand the timing, but once you've got it figured out AVRCalc helps immensely in setting up timers & UARTs.

Lee

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

[Steve types faster than I do. :) ]

Lee

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks everyone. You guys are great!

Marc