Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. /*****************************************************
  2. This program was produced by the
  3. CodeWizardAVR V2.05.0 Professional
  4. Automatic Program Generator
  5. © Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
  6. http://www.hpinfotech.com
  7.  
  8. Project :
  9. Version :
  10. Date : 09.08.2017
  11. Author :
  12. Company :
  13. Comments:
  14.  
  15.  
  16. Chip type : ATtiny2313A
  17. AVR Core Clock frequency: 16,000000 MHz
  18. Memory model : Tiny
  19. External RAM size : 0
  20. Data Stack size : 32
  21. *****************************************************/
  22.  
  23. #include <tiny2313a.h>
  24. #include <delay.h>
  25. char d=1;
  26. // External Interrupt 1 service routine
  27. interrupt [EXT_INT1] void ext_int1_isr(void)
  28. {
  29. d=0;
  30.  
  31. }
  32.  
  33. // Declare your global variables here
  34.  
  35. void main(void)
  36. {
  37. // Declare your local variables here
  38.  
  39. // Crystal Oscillator division factor: 1
  40. #pragma optsize-
  41. CLKPR=0x80;
  42. CLKPR=0x00;
  43. #ifdef _OPTIMIZE_SIZE_
  44. #pragma optsize+
  45. #endif
  46.  
  47. // Input/Output Ports initialization
  48. // Port A initialization
  49. // Func2=In Func1=In Func0=In
  50. // State2=T State1=T State0=T
  51. PORTA=0x00;
  52. DDRA=0x00;
  53.  
  54. // Port B initialization
  55. // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
  56. // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
  57. PORTB=0x00;
  58. DDRB=0xFF;
  59.  
  60. // Port D initialization
  61. // Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
  62. // State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
  63. PORTD=0x00;
  64. DDRD=0x7F;
  65.  
  66. // Timer/Counter 0 initialization
  67. // Clock source: System Clock
  68. // Clock value: Timer 0 Stopped
  69. // Mode: Normal top=0xFF
  70. // OC0A output: Disconnected
  71. // OC0B output: Disconnected
  72. TCCR0A=0x00;
  73. TCCR0B=0x00;
  74. TCNT0=0x00;
  75. OCR0A=0x00;
  76. OCR0B=0x00;
  77.  
  78. // Timer/Counter 1 initialization
  79. // Clock source: System Clock
  80. // Clock value: Timer1 Stopped
  81. // Mode: Normal top=0xFFFF
  82. // OC1A output: Discon.
  83. // OC1B output: Discon.
  84. // Noise Canceler: Off
  85. // Input Capture on Falling Edge
  86. // Timer1 Overflow Interrupt: Off
  87. // Input Capture Interrupt: Off
  88. // Compare A Match Interrupt: Off
  89. // Compare B Match Interrupt: Off
  90. TCCR1A=0x00;
  91. TCCR1B=0x00;
  92. TCNT1H=0x00;
  93. TCNT1L=0x00;
  94. ICR1H=0x00;
  95. ICR1L=0x00;
  96. OCR1AH=0x00;
  97. OCR1AL=0x00;
  98. OCR1BH=0x00;
  99. OCR1BL=0x00;
  100.  
  101. // External Interrupt(s) initialization
  102. // INT0: Off
  103. // INT1: On
  104. // INT1 Mode: Falling Edge
  105. // Interrupt on any change on pins PCINT0-7: Off
  106. GIMSK=0x80;
  107. MCUCR=0x08;
  108. EIFR=0x80;
  109.  
  110. // Timer(s)/Counter(s) Interrupt(s) initialization
  111. TIMSK=0x00;
  112.  
  113. // Universal Serial Interface initialization
  114. // Mode: Disabled
  115. // Clock source: Register & Counter=no clk.
  116. // USI Counter Overflow Interrupt: Off
  117. USICR=0x00;
  118.  
  119. // USART initialization
  120. // USART disabled
  121. UCSRB=0x00;
  122.  
  123. // Analog Comparator initialization
  124. // Analog Comparator: Off
  125. // Analog Comparator Input Capture by Timer/Counter 1: Off
  126. ACSR=0x80;
  127. DIDR=0x00;
  128.  
  129. // Global enable interrupts
  130. #asm("sei")
  131.  
  132. while (1)
  133. {
  134. if (d==1){
  135. PORTD=0b11111111;
  136. PORTB=0b01110110;
  137. PORTD=0b11111110;
  138. delay_ms(1); }
  139.  
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement