Guest User

Untitled

a guest
May 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #ifndef F_CPU
  2. #define F_CPU 1000000 // or whatever may be your frequency
  3. #endif
  4.  
  5. #include <avr/io.h> // adding header files
  6. #include <util/delay.h>
  7. #include <avr/interrupt.h> // for _delay_ms()
  8.  
  9. volatile unsigned char count=0;
  10.  
  11. ISR(INT1_vect)//increment
  12. {
  13.  
  14. count = (count+1)%16;
  15. PORTA = count;
  16. //_delay_ms(300);
  17.  
  18. GIFR = GIFR | 0b11100000;
  19.  
  20. }
  21.  
  22.  
  23. ISR(INT2_vect)//decrement
  24. {
  25.  
  26. count = (count-1+16)%16;
  27. PORTA = count;
  28. //_delay_ms(300);
  29. GIFR = GIFR | 0b11100000;
  30.  
  31. }
  32.  
  33. int main(void)
  34. {
  35. //DDRB=0;
  36. DDRA=0xFF;
  37.  
  38. MCUCR = MCUCR | 0b00001000;
  39. MCUCR = MCUCR & 0b11111011;
  40.  
  41. MCUCSR = MCUCSR & 0b10111111;
  42.  
  43. GICR = GICR | (1 << INT2) | ( 1 << INT1);
  44.  
  45. sei();
  46.  
  47.  
  48. // setting DDR of PORT C
  49.  
  50. PORTA = count;
  51.  
  52. while(1)
  53. {
  54. //nothing :P
  55. }
  56.  
  57. }
Add Comment
Please, Sign In to add comment