Line 1: Line 1:
 
[[Category:AVR Tutorials]]
 
[[Category:AVR Tutorials]]
 
=Basics=
 
=Basics=
We have covered the basics of [[AVR_Timer_programming| AVR timer Programming]], during the Timer 1 example we saw that we had to monitor the Flags to check if the Timer has overflown which made the main program dependent on the status of the flags. Timers are independent unit's inside a micro-controller and make full use of them we will configure and use them with Interrupts. This makes the CPU free from polling the flags and timers can operate on their own. When the timing task is finished, it will interrupt and inform the CPU.  
+
We have covered the basics of [[AVR_Timer_programming| AVR timer Programming]], during the Timer 1 example we saw that we had to monitor the Flags to check if the Timer has overflown which made the main program dependent on the status of the flags. Timers are independent unit's inside a micro-controller and to  make full use of them we will configure and use them with Interrupts. This makes the CPU free from polling the flags and timers can operate on their own. When the timing task is finished, it will interrupt and inform the CPU.  
 
   
 
   
 +
Let us repeat the same example of generating a 100ms delay with Timer 1 but this time using Interrupts. We have covered the [[Basics of AVR Interrupts]], you may wish to go through it first.
  
 
{| style="text-align:center;" class="table table-responsive table-bordered"  
 
{| style="text-align:center;" class="table table-responsive table-bordered"  

Revision as of 15:06, 22 March 2016

Basics

We have covered the basics of AVR timer Programming, during the Timer 1 example we saw that we had to monitor the Flags to check if the Timer has overflown which made the main program dependent on the status of the flags. Timers are independent unit's inside a micro-controller and to make full use of them we will configure and use them with Interrupts. This makes the CPU free from polling the flags and timers can operate on their own. When the timing task is finished, it will interrupt and inform the CPU.

Let us repeat the same example of generating a 100ms delay with Timer 1 but this time using Interrupts. We have covered the Basics of AVR Interrupts, you may wish to go through it first.

TIMSK
Timer/Counter Interrupt Mask Register
D7 D6 D5 D4 D3 D2 D1 D0
- - TICIE1 OCIE1A OCIE1B TOIE1 - -

Code