Advertisement
dzieciol

zadanie 2 timery popr

Nov 24th, 2017
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<avr/io.h>
  2.  
  3.  
  4.  
  5. int main(void){
  6.    
  7.     TCCR0 |=  (1<<CS02) | (1<<CS00);// ustawienie preskalera na 1024
  8.    
  9.     //TCCR0 |= ~(1<<CS01);
  10.     DDRA = 0xFF;
  11.  
  12.      while (1){
  13.         PORTA = 0x00;
  14.         opuzn(200);
  15.         PORTA = 0xFF;
  16.         opuzn(200);
  17.     }
  18.  
  19. }
  20.  
  21. int opuzn(int czas){
  22.    
  23. while(1){
  24.  
  25.     if(TIFR & (1<<TOV0)){
  26.         TIFR |= (1<<TOV0);
  27.         TCNT0 = 255 - czas;    
  28.         return 0;
  29.     }  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement