Embedded timer prescaler selection calculator

Calculate chosen prescaler and counter reload value with your own figures.

Your numbers

Use the units shown. Results update as you change valid inputs.

Use chosen prescaler and counter reload value to compare changes to your inputs. The method and limits below explain the scope.

Examples

Examples

Try the starting example

Timer clock (Hz)
48000000
Counter width (bits)
16
Target period (seconds)
0.001
Available integer prescalers
1,8,64,256
Chosen prescaler
1
Counter reload value
47999
Realized period (seconds)
0.001
Relative period error (%)
0

Try another scenario

Timer clock (Hz)
48000000
Counter width (bits)
16
Target period (seconds)
0.002
Available integer prescalers
[1, 8, 64, 256]
Chosen prescaler
8
Counter reload value
11999
Realized period (seconds)
0.002
Relative period error (%)
0
Calculation method

Calculation method

Chosen prescaler

Search supplied prescalers; choose bounded integer tick count minimizing absolute period error.

Counter reload value

Ticks−1; ticks are clamped to [1,2^width].

Realized period (seconds)

Ticks × prescaler/clock.

Relative period error (%)

100(realized−target)/target.

Symbols and units
a
Timer clock (Hz)
b
Counter width (bits)
c
Target period (seconds)
d
Available integer prescalers

Use the units shown. A list keeps the order in which you enter its values. The symbol ^ means “raised to the power of”.

Assumptions & limits

Assumptions & limits

  • Clock, timer widths, target period, available prescalers. Returns Closest realizable settings and error. All coefficients and observations are user supplied; results describe only the stated mathematical model. Quantities are deterministic calculations from supplied observations and assumptions; no external data is fetched. Supported limits: Finite inputs only; numeric fields bounded as labelled. Lists and JSON records are limited to 256 entries unless a stricter tool bound is stated. No automatic design approval, legal conclusion, treatment recommendation or safety certification. Timer clock (Hz): minimum 1e-12, maximum 1000000000000.0. Counter width (bits): minimum 1, maximum 32. Target period (seconds): minimum 1e-12, maximum 1000000000000.0. Available integer prescalers: minimum 1, maximum 1000000.
Are these inputs private?

These calculations run in your browser. A shared link contains the values you choose to share. Only questions submitted to the separate AI finder are sent to OpenAI.

Share this page
Share this calculator

Leave unchecked to share the page without your entered values.