Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. /*
  2. * main.c
  3. *
  4. * Created on: 23 mar 2019
  5. * Author: admin
  6. */
  7.  
  8. #include <avr/io.h>
  9. #include <util/delay.h>
  10. #include <avr/interrupt.h>
  11.  
  12. volatile uint8_t licznik_przerwan1;
  13. volatile uint8_t licznik_przerwan2;
  14. volatile uint8_t licznik_przerwan3;
  15.  
  16. #define CZAS_LED1 29
  17. #define CZAS_LED2 59
  18. #define CZAS_LED3 119
  19.  
  20.  
  21. int main(void) {
  22. TCCR0B = (1 << CS00) | (1 << CS02); //preskaler na 1024
  23. TIMSK0 = (1 << TOIE0); //włączenie przerwania z przepelnienia timera
  24. sei();
  25. // włączenie globalnego systemu pzerwań
  26. DDRA = (1 << PA0) | (1 << PA1) | (1 << PA2) | (1 << PA3);
  27. for (;;) {
  28.  
  29. }
  30. }
  31.  
  32. //inrerrup secial routine
  33. ISR(TIMER0_OVF_vect) {
  34. PORTA ^= (1 << PA0);
  35. //TCNT0 = 0;
  36. if (++licznik_przerwan1 > CZAS_LED1) {
  37. PORTA ^= (1 << PA1);
  38. licznik_przerwan1 = 0;
  39. }
  40.  
  41. if (++licznik_przerwan2 > CZAS_LED2) {
  42. PORTA ^= (1 << PA2);
  43. licznik_przerwan2 = 0;
  44. }
  45.  
  46. if (++licznik_przerwan3 > CZAS_LED3) {
  47. PORTA ^= (1 << PA3);
  48. licznik_przerwan3 = 0;
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement