Jak najprościej wygenerować na tiny13 3 impulsy w ciągu 1 sekundy , ale bez użycia WAIT .
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam
toggle porta.0
toggle porta.0
toggle porta.0
toggle porta.0
toggle porta.0
toggle porta.0
$regfile = "attiny13.dat"
$crystal = 4800000
Config Pinb.0 = Output
Led Alias Portb.0 'Wyjście LED
Config Pinb.5 = Input
Sw Alias Portb.5 'Switch Start
Config Timer0 = Timer , Prescale = 256
Enable Interrupts
On Timer0 Odmierz
Dim Licz_8ms As Byte
Enable Timer0
Load Timer0 = 250
Led = 1
Sw = 0
Do
Debounce Sw , 1 , Sub Generator
End 'end program
Odmierz :
Load Timer0 = 250
Incr Licz_8ms
If Licz_8ms = 125 Then
Licz_8ms = 0
Toggle Led
End If
Generator :
$regfile = "attiny13.dat"
$crystal = 4800000
Config Pinb.0 = Output
Led Alias Portb.0 'Wyjście LED
Config Pinb.5 = Input
Sw Alias Portb.5 'Switch Start
Dim Licze As Byte At &H62
Config Timer0 = Timer , Prescale = 256
Enable Interrupts
On Timer0 Odmierz
Enable Timer0
Load Timer0 = 250
Led = 1
Sw = 0
Do
Debounce Sw , 1 , Generator
Loop
End
Generator:
Gosub Odmierz
Gosub Odmierz
Gosub Odmierz
Return
Odmierz:
Load Timer0 = 250
Incr Licze
If Licze = 125 Then
Licze = 0
Toggle Led
End If
Return
'Przerwanie od przepełnienia TIMER0 jest generowane co
' 4000000Hz / 256 /125 =125 a 1/125= 8ms
' 40 * 8ms = 320ms
$regfile = "attiny13.dat"
$crystal = 4000000
Config Pinb.0 = Output
Led Alias Portb.0 'Wyjście LED
Config Pinb.5 = Input
Sw Alias Portb.5 'Switch Start
Dim Licze As Byte At &H64
Config Timer0 = Timer , Prescale = 256
Enable Interrupts
On Timer0 Odmierz
Enable Timer0
Load Timer0 = 125 '
Led = 0
Sw = 0
Do
Debounce Sw , 0 , Generator , Sub
Loop
End
Generator:
Gosub Odmierz
Gosub Odmierz
Gosub Odmierz
Return
Odmierz:
'Load Timer0 = 125
Incr Licze
If Licze = 40 Then
Licze = 0
Toggle Led
End If
Return