Napisałem taki program , który steruje pracą licznika za pomocą dwóch przycisków podłączonych do portów z wykorzystaniem przerwania INT0 , 1 . Naciśnięcie przycisku S1 (P3.2) powoduje rozpoczęcie zliczania impulsów , a S2 (P3.3) zatrzymanie i wyświetlenie wyniku.Wszystko działa bezproblemowo , ale jest jedno ale..... . Naciśnięcie przycisku S1 powoduje przeskok do podprogramu przerwania INT0 , a start licznika rozpoczyna się w momencie puszczenia przycisku . Dlaczego licznik nie zlicza od momentu wciśnięcia przycisku i wysłania polecenia START TIMER0 , tylko dopiero po puszczeniu przycisku .Czy to jest normalne czy robie coś nie tak ? Oto listing:
'89C2051'
$crystal = 11059200
Config Timer0 = Timer , Gate = External , Mode = 1
$baud = 9600
Print "Start"
Dim A As Word
Enable Interrupts
Enable Int0
Enable Int1
On Int0 Licz
On Int1 Stuj
Counter0 = 0
A = 0
Do
Set P3.7 'pętla glówna - zapalanie i gaszenie diody led
Waitms 250
Reset P3.7
Waitms 250
Loop
End
Licz:
Disable Int0
Counter0 = 0
Start Timer0
Print "Start = " ; A
Enable Int1
Return
Stuj:
Disable Int1
Stop Timer0
A = Counter0
Print "Stop = " ; A
A = 0
Enable Int0
Return
'89C2051'
$crystal = 11059200
Config Timer0 = Timer , Gate = External , Mode = 1
$baud = 9600
Print "Start"
Dim A As Word
Enable Interrupts
Enable Int0
Enable Int1
On Int0 Licz
On Int1 Stuj
Counter0 = 0
A = 0
Do
Set P3.7 'pętla glówna - zapalanie i gaszenie diody led
Waitms 250
Reset P3.7
Waitms 250
Loop
End
Licz:
Disable Int0
Counter0 = 0
Start Timer0
Print "Start = " ; A
Enable Int1
Return
Stuj:
Disable Int1
Stop Timer0
A = Counter0
Print "Stop = " ; A
A = 0
Enable Int0
Return
[/img][/url]