Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. ;
  2. ; ARBK_Praktikum_4_Polling.asm
  3. ;
  4.  
  5. ; Definitions
  6. .def temp = r16
  7. .def leds = r17
  8. .def counter0 = r18
  9. .def counter1 = r19
  10. .def counter2 = r20
  11.  
  12.  
  13. ; Jump Table
  14. .org 0x00 ; Reset Handler
  15. rjmp main
  16.  
  17. main:
  18. ; DDR setzen
  19. ldi temp,0xFF
  20. out DDRB,temp
  21. ldi temp,0x00
  22. out DDRD,temp
  23. ldi temp,0xFF
  24. out PORTD,temp
  25. ; LEDs ausschalten
  26. ldi leds,0x00
  27. out PORTB,leds
  28. ; stackpointer
  29. ldi temp,HIGH(RAMEND)
  30. out SPH,temp
  31. ldi temp,LOW(RAMEND)
  32. out SPL,temp
  33.  
  34. ;blinken
  35. blink:
  36. rcall taster
  37. out PORTB,leds
  38. rcall wait
  39. ldi temp,0x00
  40. out PORTB,temp
  41. rcall wait
  42. rjmp blink
  43.  
  44. ; taster auswerten
  45. taster:
  46. in temp,PIND
  47. cbr temp,251
  48. cpi temp,0
  49. breq ledR
  50. in temp,PIND
  51. cbr temp,247
  52. cpi temp,0
  53. breq ledY
  54. ret
  55.  
  56. ledY:
  57. cpi leds,0x02
  58. breq turnoff
  59. ldi leds,0x02
  60. ret
  61.  
  62. ledR:
  63. cpi leds,0x01
  64. breq turnoff
  65. ldi leds,0x01
  66. ret
  67.  
  68. turnoff:
  69. ldi leds,0x00
  70. ret
  71.  
  72. ; warten
  73. wait:
  74. inc counter0
  75. cpi counter0,0xFF
  76. brlo wait
  77.  
  78. inc counter1
  79. cpi counter1,0xFF
  80. brlo wait
  81.  
  82. inc counter2
  83. cpi counter2,0x07
  84. brlo wait
  85.  
  86. ldi counter0,0x00
  87. ldi counter1,0x00
  88. ldi counter2,0x00
  89.  
  90. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement