Advertisement
gabrielaozegovic

Untitled

Dec 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. .def tmp = r16
  2. .def mask = r17
  3. .def counter = r18
  4. .def step = r22
  5.  
  6. .cseg
  7. rjmp reset
  8.  
  9.  
  10. .org $002
  11. rjmp i0
  12. .org $004
  13. rjmp i1
  14. .org $00C
  15. rjmp dimaj
  16. .org $010
  17. rjmp dimaj
  18.  
  19.  
  20. reset:
  21. ldi tmp, high(RAMEND)
  22. out SPH, tmp
  23. ldi tmp, low(RAMEND)
  24. out SPL, tmp
  25.  
  26. ldi tmp, 0xff
  27. out PORTA, tmp
  28. out DDRA, tmp
  29.  
  30. ldi tmp, (1 << WGM10)
  31. out TCCR1A, tmp
  32.  
  33. ldi tmp, (1 << WGM12) | (1 << CS10)
  34. out TCCR1B, tmp
  35.  
  36. ldi tmp, 130
  37. out OCR1AL, tmp
  38.  
  39. ldi tmp, (1 << OCIE1A) | (1 << TOIE1)
  40. out TIMSK, tmp
  41.  
  42. ldi tmp, (1 << ISC11) | (1 << ISC01)
  43. out MCUCR, tmp
  44.  
  45. ldi tmp, (1 << INT0) | (1 << INT1)
  46. out GICR, tmp
  47.  
  48. sei
  49.  
  50. ldi tmp, 0xff
  51. ldi mask, 0x01
  52. ldi step, 5
  53.  
  54. start:
  55.  
  56. rjmp start
  57.  
  58.  
  59. dimaj:
  60. in tmp, PORTA
  61. eor tmp, mask
  62. out PORTA, tmp
  63. reti
  64.  
  65.  
  66.  
  67. i0:
  68. in counter, OCR1AL
  69.  
  70. cpi counter, 245
  71. brne i0_jump
  72. rjmp i0_end
  73. i0_jump:
  74. add counter, step
  75. i0_end:
  76. out OCR1AL, counter
  77. reti
  78.  
  79.  
  80. i1:
  81. in counter, OCR1AL
  82.  
  83. cpi counter, 10
  84. brne i1_jump
  85. rjmp i1_end
  86. i1_jump:
  87. sub counter, step
  88. i1_end:
  89. out OCR1AL, counter
  90. reti
  91.  
  92.  
  93.  
  94. debounce:
  95. clr r19
  96. clr r20
  97. ldi r21, 4
  98.  
  99. delay_loop:
  100. dec r19
  101. brne delay_loop
  102. dec r20
  103. brne delay_loop
  104. dec r21
  105. brne delay_loop
  106.  
  107. push tmp
  108. ldi tmp, (1 << INTF0) | (1 << INTF1)
  109. out GIFR, tmp
  110. pop tmp
  111. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement