Advertisement
Guest User

andrea

a guest
Jun 18th, 2018
2,811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /*
  2. * tes_time.c
  3. *
  4. * Created: 18/06/2018 09:38:18
  5. * Author: Andrea
  6. */
  7.  
  8.  
  9. #include <avr/io.h>
  10. #include <avr/interrupt.h>
  11. int i;
  12. int s;
  13. int main(void)
  14. {
  15. DDRD &= ~(1 << DDD2);
  16. DDRC = 0xFF;
  17.  
  18.  
  19.  
  20.  
  21. PORTD |= (1 << PORTD2);
  22. //registri pulsante
  23. EICRA=0X2;
  24. EIMSK |= (1 << INT0);
  25. //registri timer
  26. TCCR0A |= (1 << WGM01); //CTC mode TC0 (OCR0A -> TOP)
  27. TCCR0B |=((1 << CS02) |(1 << CS00)); //Prescaler 1024 (1 clk = 64 us)
  28. TIMSK0 = 0x00; //Interrupt compare A disabled
  29. OCR0A = 156;
  30. sei();
  31.  
  32. while(1)
  33. {
  34. i=0;
  35. s=0;
  36. PORTC|= (1 << PORTC0);
  37. if(s=5){
  38. PORTC|= (1 << PORTC1);}
  39. if(s=10){
  40. PORTC|= (1 << PORTC2);}
  41. if(s=15){
  42. PORTC|= (1 << PORTC3);}
  43. if(s=20){
  44. PORTC|= (1 << PORTC4); }
  45. if(s=25){
  46. PORTC|= (1 << PORTC5);
  47. i=0;
  48. s=0;}
  49.  
  50. }
  51. }
  52. ISR (INT0_vect) {
  53. PORTC=0x0;
  54.  
  55.  
  56. TIMSK0 = 0x02;
  57.  
  58. }
  59. ISR (TIMER0_COMPA_vect) // Timer/Counter0 Compare Match A interrupt service routine
  60. { i++;
  61. if(i=200){s++;}
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement