Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "attiny2313.dat"
- $crystal = 8000000
- Config Pind.0 = Output
- Config Pinb.0 = Input
- Pinb.0 = 1 'przycisk "TEMPO"
- Config Debounce = 1
- Config Int0 = Falling ' przycisk "wymuszony start"
- Config Timer0 = Timer , Prescale = 64
- On Timer0 Przerwanie_co_1ms
- On Int0 Zeruj
- Led Alias Portd.0
- Portd.0 = 1
- Dim Granica As Word
- Dim Licznik As Word
- Dim Odlicz As Word
- Dim Tik As Bit
- Granica = 1000
- Odlicz = 0
- Licznik = 0
- Tik = 0
- Enable Interrupts
- Enable Timer0
- Enable Int0
- Timer0 = 6
- Start Timer0
- '-------------------------------------------
- Glowna:
- Do
- Debounce Pinb.0 , 0 , Zacznij , Sub
- If Tik = 1 Then
- Gosub Petla
- End If
- Loop
- '-------------------------------------------
- Petla:
- If Odlicz = Granica Then
- Reset Portd.0
- Odlicz = 0
- End If
- If Odlicz >= 2 Then
- Set Portd.0
- End If
- Incr Odlicz
- Reset Tik
- Return
- '------------------------------------------- start licznika
- Zacznij:
- Licznik = 0
- Do
- Debounce Pinb.0 , 0 , Zakoncz , Sub
- Loop
- '------------------------------------------- 2 klik - zakończ przechwytywanie
- Zakoncz:
- Stop Timer0
- Gosub Przepisz
- Start Timer0
- Gosub Glowna
- '------------------------------------------- przepisanie zmiennej
- Przepisz:
- Granica = Licznik
- Odlicz = 0
- Return
- '------------------------------------------- +131 dla uzyskania 1mS
- Przerwanie_co_1ms:
- Counter0 = Counter0 + 131
- Incr Licznik
- Set Tik
- Return
- '-------------------------------------------
- Zeruj:
- Odlicz = Granica
- Counter0 = Counter0 + 131
- Return
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement