Guest User

Untitled

a guest
Jun 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. volatile unsigned char i;
  5.  
  6. // pretečenie počítadla TCNT0 - nastane každých 128us*256 = 32,768ms
  7. ISR (TIM0_OVF_vect){
  8.  
  9.     // 15*32.768 = 491,52ms
  10.     if(i == 15){
  11.     PORTD ^= (1 << PD7); // finta s log. operáciou XOR - neguje len pin PD7
  12.     i=0;
  13.     }
  14.  
  15.     i++;
  16.  
  17. }
  18.  
  19. int main(){
  20.  
  21.     DDRD |= (1 << PD7); // PD7 ako výstupný
  22.    
  23.  
  24.     TCCR0 |= (1 << CS02) | (1 << CS00); // preddelicka /1024 (128us)
  25.     TIMSK |= (1 << TOIE0);              // prerušenie pri pretečení TCNT0
  26.  
  27.  
  28.     sei(); //povol globálne prerušenia
  29.  
  30.     while(1); //nekonenčná slučka
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment