Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #define F_CPU 7372800UL
  2.  
  3.  
  4. #include <avr/io.h>
  5. #include <avr/interrupt.h>
  6. #include <util/delay.h>
  7. #include "lcd.h"
  8.  
  9.  
  10. int counter = 0;
  11.  
  12.  
  13. ISR(INT0_vect)
  14. {
  15. lcd_clrscr();
  16. lcd_gotoxy(3, 0);
  17. lcd_puts("20.01.2019.");
  18. lcd_gotoxy(3, 1);
  19. lcd_puts("Matej Duvnjak");
  20.  
  21. /*Napraviti preko Timera, a ne delaya jer ako koristimo timer onesposobljujemo rad
  22. mikrokontrolera, s timerom i dalje ga mozemo koristiti*/
  23. //_delay_ms(15000);
  24. //lcd_clrscr();
  25.  
  26. TCCR0 |= _BV(CS02) | _BV(CS00); //pokreni timer | zelimo sacuvati vrijednosti koje smo defiirali u mainu
  27. }
  28.  
  29. ISR(TIMER0_COMP_vect)
  30. {
  31. counter++;
  32.  
  33. if(counter == 750)
  34. {
  35. lcd_clrscr();
  36. TCCR0 = _BV(WGM01); //resetriaj timer | pauziramo ga
  37. counter = 0;
  38. }
  39. }
  40.  
  41.  
  42. int main(void)
  43. {
  44. DDRD = _BV(4);
  45. TCCR1A = _BV(COM1B1) | _BV(WGM10);
  46. TCCR1B = _BV(WGM12) | _BV(CS11);
  47. OCR1B = 128;
  48.  
  49. //TCCR0 = _BV(WGM01) | _BV(CS02) | _BV(CS00);
  50. TCCR0 = _BV(WGM01);
  51. OCR0 = 143;
  52. TIMSK = _BV(OCIE0);
  53.  
  54. MCUCR = _BV(ISC00) | _BV(ISC01);
  55. GICR = _BV(INT0);
  56.  
  57. sei();
  58.  
  59. lcd_init(LCD_DISP_ON);
  60. lcd_clrscr();
  61.  
  62. while (1);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement