Experiment 2
Experiment 2
Aim: To generate a time delay using timers in a microcontroller and understand how timer
registers are configured to achieve precise delays.
Apparatus Required:
Theory: Timers in microcontrollers are used to generate precise time delays and perform
various time-based operations. They work by counting clock pulses and generating an interrupt
or overflow when a predefined value is reached.
Working of a Timer:
2. Prescaler: Divides the clock frequency to slow down the timer counting rate.
3. Timer Mode:
- Timer Mode: The timer counts internal clock cycles to generate a delay.
4. Overflow: When the timer register overflows, an interrupt is triggered or a flag is set.
Program:
void main() {
while(1) {
unsigned int i;
Result: The experiment to generate a time delay using timers in a microcontroller was successfully
performed. The timer was configured in the appropriate mode, and the expected delay was achieved. The
microcontroller counted clock pulses accurately and generated the required delay.