# 5. Delay Using Timers

## 5.1. Delay Calculation in Normal Mode

In **Normal Mode**, the timer always counts up to its maximum value and then overflows. To get a specific delay, you **preload the TCNTn register** with a starting value so it only has to count a specific number of steps before overflowing.

Here is the formula to find the **required preload value**:  
[![](https://learn.digilabdte.com/uploads/images/gallery/2026-03/scaled-1680-/image-1772552759954.png)](https://learn.digilabdte.com/uploads/images/gallery/2026-03/image-1772552759954.png)

For example, if we want to create a **1ms delay** using **Timer0** with **1/64 presacaler**:  
[![](https://learn.digilabdte.com/uploads/images/gallery/2026-03/scaled-1680-/image-1772552806881.png)](https://learn.digilabdte.com/uploads/images/gallery/2026-03/image-1772552806881.png)

## 5.2. Delay Calculation in CTC Mode

In **CTC (Clear Timer on Compare) Mode**, the timer is much easier to use for delays because the hardware automatically resets the counter to zero when it reaches a target value stored in the **OCRnx (Output Compare Register)**.

Here is the formula to find **the value to put in OCRnx register**:  
[![](https://learn.digilabdte.com/uploads/images/gallery/2026-03/scaled-1680-/image-1772552838331.png)](https://learn.digilabdte.com/uploads/images/gallery/2026-03/image-1772552838331.png)

For example, if we want to create a **1ms delay** using **Timer0** with **1/64 presacaler**:  
[![](https://learn.digilabdte.com/uploads/images/gallery/2026-03/scaled-1680-/image-1772552868798.png)](https://learn.digilabdte.com/uploads/images/gallery/2026-03/image-1772552868798.png)