Advertisement
bart_moran

Untitled

May 16th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 0 = 0b00000000 = 0x00
  2. // 1 = 0b00000001 = 0x01
  3. // 2 = 0b00000010 = 0x02
  4. // 3 = 0b00000100 = 0x04
  5. // 4 = 0b00001000 = 0x08
  6. // 5 = 0b00010000 = 0x10
  7. // 6 = 0b00100000 = 0x20
  8. // 7 = 0b01000000 = 0x40
  9. // 8 = 0b10000000 = 0x80
  10.  
  11.  
  12. // UBRR = 8000000 / (16 * 1200) - 1 = 415
  13. // BAUD = 8000000 / (16 * (415 + 1)) = 1200
  14.  
  15.  
  16. .include "m16def.inc"
  17. .org 0x0000 // kod po adressu 0
  18.  
  19.  
  20. .def temp = r16
  21. .def data = r17
  22.  
  23. .def c1= r19
  24. .def c2 = r20
  25. .def c3= r21
  26. .def c4 = r22
  27. .def c5= r23
  28. .def c = r24
  29.  
  30.  
  31. .equ Bitrate = 1200
  32. .equ UBRR = 415
  33.  
  34. ldi temp, high(RAMEND)
  35. out SPH, temp
  36. ldi temp, low(RAMEND)
  37. out SPL, temp
  38.  
  39. ldi temp, high(415) //skorost 1200 baud
  40. out UBRRH, temp
  41. ldi temp, low(415)
  42. out UBRRL, temp
  43.  
  44. ldi temp, (1 << TXEN) | (1 << RXEN) //vklu4aem peredat4ik i priemnik
  45. out UCSRB, temp
  46. ldi temp, (1 << UCSZ1) | (1 << UCSZ0) | (1 << URSEL)
  47. out UCSRC, temp
  48.  
  49. ldi temp, 0x1f
  50. out DDRA, temp
  51. ldi temp, 0x00
  52. out PORTA, temp
  53.  
  54.  
  55.  
  56. ldi c1, 0b00000001
  57. ldi c2, 0b00000010
  58. ldi c3, 0b00000100
  59. ldi c4, 0b00001000
  60. ldi c5, 0b00010000
  61. ldi c, 0
  62.  
  63. ldi temp, 0x00
  64. Proga:
  65. rcall get_byte
  66. cpi data, '0'
  67. breq led_off
  68.  
  69. cpi data, '1'
  70. breq led1_on
  71.  
  72.  
  73. cpi data, '2'
  74. breq led2_on
  75.  
  76.  
  77. cpi data, '3'
  78. breq led3_on
  79.  
  80.  
  81. cpi data, '4'
  82. breq led4_on
  83.  
  84.  
  85. cpi data, '5'
  86. breq led5_on
  87.  
  88.  
  89.  
  90. cpi data, '9'
  91. breq sdvig
  92.  
  93. rjmp Proga
  94.  
  95.  
  96.  
  97. sdvig:
  98.  
  99. rol temp
  100. sbic PINA, 4
  101. add temp, c1
  102. out PORTA, temp
  103. rjmp Proga
  104.  
  105. get_byte:
  106. sbis UCSRA, RXC
  107. rjmp PC-1
  108. in data, UDR
  109. ret
  110.  
  111. led_off:
  112. ldi temp, 0x00
  113. out PORTA, temp
  114. rjmp Proga
  115. ///////////////////////////
  116. led1_on:
  117. sbic PINA, 0
  118. rcall led1_off
  119.  
  120. sbis PINA, 0
  121. add temp, c1
  122. out PORTA, temp
  123. rjmp Proga
  124.  
  125. led1_off:
  126. sbic PINA, 0
  127. sub temp, c1
  128. out PORTA, temp
  129. rjmp Proga
  130. /////////////////////
  131. led2_on:
  132. sbic PINA, 1
  133. rcall led2_off
  134.  
  135. sbis PINA, 1
  136. add temp, c2
  137. out PORTA, temp
  138. rjmp Proga
  139.  
  140. led2_off:
  141. sbic PINA, 1
  142. sub temp, c2
  143. out PORTA, temp
  144. rjmp Proga
  145. ////////////////////////////
  146. led3_on:
  147. sbic PINA, 2
  148. rcall led3_off
  149.  
  150. sbis PINA, 2
  151. add temp, c3
  152. out PORTA, temp
  153. rjmp Proga
  154.  
  155. led3_off:
  156. sbic PINA, 2
  157. sub temp, c3
  158. out PORTA, temp
  159. rjmp Proga
  160. ////////////////////////////
  161. led4_on:
  162. sbic PINA, 3
  163. rcall led4_off
  164.  
  165. sbis PINA, 3
  166. add temp, c4
  167. out PORTA, temp
  168. rjmp Proga
  169.  
  170. led4_off:
  171. sbic PINA, 3
  172. sub temp, c4
  173. out PORTA, temp
  174. rjmp Proga
  175. ////////////////////////////
  176. led5_on:
  177. sbic PINA, 4
  178. rcall led5_off
  179.  
  180. sbis PINA, 4
  181. add temp, c5
  182. out PORTA, temp
  183. rjmp Proga
  184.  
  185. led5_off:
  186. sbic PINA, 4
  187. sub temp, c5
  188. out PORTA, temp
  189. rjmp Proga
  190. ////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement