Advertisement
Guest User

Tap

a guest
Sep 1st, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $regfile = "attiny2313.dat"
  2. $crystal = 8000000
  3.  
  4.  
  5. Config Pind.0 = Output
  6. Config Pinb.0 = Input
  7.  
  8. Pinb.0 = 1                                                  'przycisk "TEMPO"
  9.  
  10. Config Debounce = 1
  11.  
  12. Config Int0 = Falling                                       ' przycisk "wymuszony start"
  13. Config Timer0 = Timer , Prescale = 64
  14. On Timer0 Przerwanie_co_1ms
  15. On Int0 Zeruj
  16.  
  17. Led Alias Portd.0
  18. Portd.0 = 1
  19.  
  20.  
  21. Dim Granica As Word
  22. Dim Licznik As Word
  23. Dim Odlicz As Word
  24. Dim Tik As Bit
  25.  
  26. Granica = 1000
  27. Odlicz = 0
  28. Licznik = 0
  29. Tik = 0
  30.  
  31. Enable Interrupts
  32. Enable Timer0
  33. Enable Int0
  34. Timer0 = 6
  35. Start Timer0
  36.  
  37.  
  38. '-------------------------------------------
  39. Glowna:
  40. Do
  41.    Debounce Pinb.0 , 0 , Zacznij , Sub
  42.       If Tik = 1 Then
  43.       Gosub Petla
  44.    End If
  45. Loop
  46.  
  47. '-------------------------------------------
  48. Petla:
  49.  
  50.  
  51. If Odlicz = Granica Then
  52. Reset Portd.0
  53.    Odlicz = 0
  54. End If
  55.  
  56. If Odlicz >= 2 Then
  57. Set Portd.0
  58. End If
  59.  
  60. Incr Odlicz
  61.  
  62. Reset Tik
  63.  
  64. Return
  65.  
  66.  
  67. '-------------------------------------------  start licznika
  68. Zacznij:
  69.  
  70. Licznik = 0
  71.  
  72. Do
  73.    Debounce Pinb.0 , 0 , Zakoncz , Sub
  74. Loop
  75.  
  76. '-------------------------------------------  2 klik - zakończ przechwytywanie
  77. Zakoncz:
  78. Stop Timer0
  79. Gosub Przepisz
  80. Start Timer0
  81. Gosub Glowna
  82.  
  83. '-------------------------------------------  przepisanie zmiennej
  84. Przepisz:
  85. Granica = Licznik
  86. Odlicz = 0
  87. Return
  88.  
  89. '------------------------------------------- +131 dla uzyskania 1mS
  90. Przerwanie_co_1ms:
  91.  
  92. Counter0 = Counter0 + 131
  93.  
  94. Incr Licznik
  95.  
  96. Set Tik
  97.  
  98. Return
  99. '-------------------------------------------
  100. Zeruj:
  101. Odlicz = Granica
  102. Counter0 = Counter0 + 131
  103. Return
  104.  
  105. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement