Advertisement
tourniquet

AVR Light effect

Feb 7th, 2014
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. .include "tn2313adef.inc"
  2. .list
  3.  
  4. .def temp = R16
  5. .def loop = R17
  6.  
  7. .equ kdel = 300
  8.  
  9. ; -----
  10.  
  11. .cseg
  12. .org 0
  13.  
  14. ; -----
  15.  
  16. ldi temp, RAMEND
  17. out SPL, temp
  18.  
  19. ; -----
  20.  
  21. ser temp
  22. out DDRB, temp
  23. out DDRD, temp
  24. out PortB, temp
  25. out PortD, temp
  26.  
  27. ; -----
  28.  
  29. ldi temp, 0x80
  30. out ACSR, temp
  31.  
  32. ; -----
  33.  
  34. ldi temp, 0x04
  35. out TCCR1B, temp
  36.  
  37. ; -----
  38.  
  39. Main:
  40. ldi loop, 2
  41.  
  42. FirstLight:
  43. cbi PortD, 0
  44. rcall Timer
  45. sbi PortD, 0
  46. cbi PortD, 1
  47. rcall Timer
  48. sbi PortD, 1
  49. dec loop
  50.  
  51. brne FirstLight
  52.  
  53. ldi loop, 2
  54.  
  55. SecondLight:
  56. cbi PortD, 2
  57. rcall Timer
  58. sbi PortD, 2
  59. cbi PortD, 3
  60. rcall Timer
  61. sbi PortD, 3
  62. dec loop
  63.  
  64. brne SecondLight
  65.  
  66. rjmp Main
  67.  
  68. Timer:
  69. push loop
  70.  
  71. ldi temp, 0
  72. out TCNT1H, temp
  73. out TCNT1L, temp
  74.  
  75. TimerLoop:
  76. in temp, TCNT1L
  77. cpi temp, low(kdel)
  78. brlo TimerLoop
  79.  
  80. in temp, TCNT1H
  81. cpi temp, high(kdel)
  82. brlo TimerLoop
  83.  
  84. pop loop
  85. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement