Skip to content
Snippets Groups Projects
avr_code.ino 438 B
Newer Older
  • Learn to ignore specific revisions
  • Markus Scheck's avatar
    Markus Scheck committed
    #include "timer_1.h"
    #include "pinchange.h"
    #include <avr/io.h>
    
    int main(void) {
    
    
    Markus Scheck's avatar
    Markus Scheck committed
      // enable serial port for output
    
    Markus Scheck's avatar
    Markus Scheck committed
      Serial.begin(9600);
    
    Markus Scheck's avatar
    Markus Scheck committed
      // init hardware timer
    
    Markus Scheck's avatar
    Markus Scheck committed
      timer_init();
    
    Markus Scheck's avatar
    Markus Scheck committed
      // init pin change interrupt
    
    Markus Scheck's avatar
    Markus Scheck committed
      init_pc();
    
    
    Markus Scheck's avatar
    Markus Scheck committed
    
      // enable interrupts
      sei();
    
    Markus Scheck's avatar
    Markus Scheck committed
      // start time measurement
    
    Markus Scheck's avatar
    Markus Scheck committed
      timer_start();
    
    Markus Scheck's avatar
    Markus Scheck committed
      PORTA = 0xff; // trigger own interrupt
    
    Markus Scheck's avatar
    Markus Scheck committed
    
      // timer will be stopped in pc interrupt
    
      while(1) {
      }
    
    Markus Scheck's avatar
    Markus Scheck committed
    }