gabrielaozegovic

6 - 3

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