Guest User

Untitled

a guest
Jan 4th, 2012
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .equ XTAL = 10000000 ;Hz
  2.  
  3. .equ Port_H = PORTA
  4. .equ Direct_H = DDRA
  5. .equ Port_L = PORTC
  6. .equ Direct_L = DDRC
  7. .equ Display_P = PORTD
  8. .equ Display_D = DDRD
  9.  
  10. //= R9
  11. //= R10
  12. //= R11
  13. //= R12
  14. .def tmp_buf = R10
  15. .def ADDR_L = R13
  16. .def ADDR_H = R14
  17. .def IDX_REG_2 = R15
  18. .def SUB_REG_2 = R16
  19. .def IDX_REG = R17
  20. .def SUB_REG = R18
  21. .def seg = R19
  22. .def _ICs = R20
  23. .def sel = R21
  24. .def KBD_VALUE = R22
  25. .def delay_count = R23
  26. .def DELAY_CICLE_HIGH = R24
  27. .def DELAY_CICLE_LOW = R25
  28. //= R29
  29. //= R30
  30. //= R31
  31.  
  32. .equ KEY_UP_BIT = PINB0
  33. .equ KEY_DOWN_BIT = PINB1
  34. .equ KEY_SEARCH_BIT = PINB2
  35. .equ KEY_TEST_BIT = PINB3
  36.  
  37. .include "macro.inc"
  38.  
  39. .DSEG
  40. sum: .db 4
  41.  
  42.  
  43. .CSEG
  44. .ORG 0x0000
  45. JMP start
  46. ; векторы прерываний
  47. .ORG INT0addr ; External Interrupt Request 0
  48. RETI
  49. .ORG INT1addr ; External Interrupt Request 1
  50. RETI
  51. .ORG OC2addr ; Timer/Counter2 Compare Match
  52. RETI
  53. .ORG OVF2addr ; Timer/Counter2 Overflow
  54. RETI
  55. .ORG ICP1addr ; Timer/Counter1 Capture Event
  56. RETI
  57. .ORG OC1Aaddr ; Timer/Counter1 Compare Match A
  58. RETI
  59. .ORG OC1Baddr ; Timer/Counter1 Compare Match B
  60. RETI
  61. .ORG OVF1addr ; Timer/Counter1 Overflow
  62. RETI
  63. .ORG OVF0addr ; Timer/Counter0 Overflow
  64. RETI
  65. .ORG SPIaddr ; Serial Transfer Complete
  66. RETI
  67. .ORG URXCaddr ; USART, Rx Complete
  68. RETI
  69. .ORG UDREaddr ; USART Data Register Empty
  70. RETI
  71. .ORG UTXCaddr ; USART, Tx Complete
  72. RETI
  73. .ORG ADCCaddr ; ADC Conversion Complete
  74. RETI
  75. .ORG ERDYaddr ; EEPROM Ready
  76. RETI
  77. .ORG ACIaddr ; Analog Comparator
  78. RETI
  79. .ORG TWIaddr ; 2-wire Serial Interface
  80. RETI
  81. .ORG INT2addr ; External Interrupt Request 2
  82. RETI
  83. .ORG OC0addr ; Timer/Counter0 Compare Match
  84. jmp ShowDisplay
  85. .ORG SPMRaddr ; Store Program Memory Ready
  86. RETI
  87.  
  88. start:
  89. ; инициализация
  90. Init
  91. ; установка начала стека
  92. LDI R16,Low(RAMEND)
  93. OUT SPL,R16
  94. LDI R16,High(RAMEND)
  95. OUT SPH,R16
  96. ; настройка портов ввода-вывода
  97. rcall init_tester
  98. sei
  99. loop:
  100. in KBD_VALUE,PORTB
  101. sbrs KBD_VALUE,KEY_UP_BIT
  102. jmp key_up
  103. sbrs KBD_VALUE,KEY_DOWN_BIT
  104. jmp key_down
  105. sbrs KBD_VALUE,KEY_SEARCH_BIT
  106. jmp key_search
  107. sbrs KBD_VALUE,KEY_TEST_BIT
  108. jmp key_test
  109. jmp key_no
  110. key_up:
  111. cp sel,_ICs
  112. breq up_no
  113. inc sel
  114. ;sbi PORTA,PINA0;
  115. brcs up_ok
  116. up_no:
  117. ldi sel,0
  118. up_ok:
  119. rcall menu
  120. up_loop:
  121. sbis PORTB,KEY_UP_BIT
  122. rjmp up_loop
  123. rjmp key_no
  124. key_down:
  125. cpi sel,0
  126. breq down_no
  127. dec sel
  128. ;cbi PORTA,PINA0;
  129. brcc down_ok
  130. down_no:
  131. mov sel,_ICs
  132. down_ok:
  133. rcall menu
  134. down_loop:
  135. sbis PORTB,KEY_DOWN_BIT
  136. rjmp down_loop
  137. rjmp key_no
  138. key_search:
  139.  
  140. search_loop:
  141. sbis PORTB,KEY_SEARCH_BIT
  142. rjmp search_loop
  143. rjmp key_no
  144. key_test:
  145. //indexed_call IC_table_1,sel,icall
  146. delay 200
  147. rjmp key_no
  148. key_no:
  149. ;rcall menu
  150. jmp loop
  151.  
  152. .include "tester.inc"
RAW Paste Data