Arduino Timer Calculator

Normal Mode

Inputs Results
Timer 0 Block Diagram

About Arduino Timer 0 Calculator

The Normal Mode calculator helps you calculate the timer/counter 0 count value (C) to load into the TCNT0 register for a given CPU frequency and required time delay. It also calculates the CPU time period and number of clock ticks required. Suitable for ATmega328P based boards such as Arduino Uno and Nano.

Equations Used

\(C=256-\frac{F_{CPU}}{N F_{d}}\)   where N is the pre-scalar value
\(F_d=\frac{1}{T_d}\)   where \(T_d\) is the required time delay
\(T_{CPU}=N\times\frac{1}{F_{CPU}}\)
\(N_c=\frac{T_d}{T_{CPU}}\)

CTC Mode

Inputs Results
Arduino ATmega328p timer/counter0 diagram

About Arduino Timer 0 CTC Mode Calculator

The CTC Mode calculator helps you calculate the timer/counter 0 count value (C) to load into the OCR0 register for a given CPU frequency and desired output wave frequency.

Equations Used

\(C=\frac{F_{osc}}{2 N F_{w}}-1\)
where Fosc is the CPU frequency, Fw is the output square wave frequency and N is the pre-scalar value.

Fast PWM Mode

Non-Inverted Mode Results

Inverted Mode

Results
Arduino fast PWM mode diagram

About Arduino Timer 0 Fast PWM Mode Calculator

The Fast PWM calculator calculates the wave frequency and OCR0 register value for both non-inverted and inverted modes.

Equations Used

\(F_{w}=\frac{F_{osc}}{256N}\)
\(OCR0_{non\text{-}inv} = \frac{256D}{100} - 1\)
\(OCR0_{inv} = 255 - \frac{256D}{100}\)

Phase Correct PWM Mode

Non-Inverted Mode Results

Inverted Mode

Results
Arduino Phase Correct PWM mode

About Arduino Timer 0 Phase Correct PWM Mode Calculator

The Phase Correct PWM calculator calculates the wave frequency and OCR0 register value for both non-inverted and inverted modes.

Equations Used

\(F_{w}=\frac{F_{osc}}{510N}\)
\(OCR0_{non\text{-}inv} = \frac{255D}{100}\)
\(OCR0_{inv} = 255 - \frac{255D}{100}\)

Post a Comment