Operácie

AVR ExampleT1int.c

Z SensorWiki

Verzia z 20:39, 18. november 2008, ktorú vytvoril Balogh (diskusia | príspevky) (Nová stránka: <source lang="c"> #include <avr/io.h> #include <avr/interrupt.h> // if ( (TIFR1 & 0x01) == 0x01) // If the overflow flag is set // ... then following Interrupt routine is called...)
(rozdiel) ← Staršia verzia | Aktuálna úprava (rozdiel) | Novšia verzia → (rozdiel)
#include <avr/io.h>
#include <avr/interrupt.h>


//  if ( (TIFR1 & 0x01) == 0x01)  // If the overflow flag is set
//  ... then following Interrupt routine is called

ISR (TIMER1_OVF_vect)          
 { 
	   PORTB = PORTB ^ 0b????????; // Toggle the LED
           TCNT1 = 0x????;             // Restart T/C1 - reload
	// Following is not necessary as it is cleared automatically
        // TIFR1 = 0x01;               // Clear the overflow flag
  }
      
int main( void )
{
  /* *********************** Init device ************************************ */

  ...

// Enable interrupts:

  TIMSK1 = 0x01;            // Timer 1 overflow interrupt enable
   sei();                   // Assembler macro for global int. enable


  /* *********************** Main Loop ************************************** */

  do {

        asm("nop");                 // Do nothing

  } while(1);                       // And do this forever


 return(0);
}

Návrat na cvičenie...