Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /*
  2. * Exp32.c
  3. *
  4. * Created: 10/23/2017 5:35:00 PM
  5. * Author: ASUS
  6. */
  7.  
  8.  
  9. /*
  10. * experiment03.c
  11. *
  12. * Created: 10/21/2017 9:35:09 PM
  13. * Author: Rifat Rahman
  14. */
  15. #define F_CPU 1000000UL
  16.  
  17. #include <avr/io.h>
  18. #include <avr/interrupt.h>
  19. #include <util/delay.h>
  20.  
  21. volatile char c;
  22.  
  23. ISR(INT2_vect)
  24. {
  25. cli();
  26. c++;
  27.  
  28. _delay_ms(500);
  29. if(c>15) c=0;
  30. c = c & 0x0f;
  31. GIFR = 0xFF;
  32.  
  33. }
  34.  
  35. ISR(INT0_vect)
  36. {
  37. cli();
  38. c--;
  39.  
  40. _delay_ms(500);
  41. if(c<0) c=15;
  42. c = c & 0x0f;
  43. GIFR = 0xFF;
  44. }
  45.  
  46. int main(void)
  47. {
  48. c = 0x00;
  49. DDRA = 0xff;
  50. GICR = (1 << INT0) | (1 << INT2);
  51. MCUCR = MCUCR | 0x2;
  52. MCUCSR = MCUCSR | 0xdf;
  53. sei();
  54.  
  55. while(1)
  56. {
  57. //TODO:: Please write your application code
  58. PORTA = c;
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement