Kawałek docelowego programu działa sprawnie, ale jak dodam "pozostałe funkcje, już niestety nie... Nie zmienia mi zmiennej "Stan" i nie wysyła ATH tym samym nie przechodzi do następnego etapu programu...
Kod działający:
Kod nie działający:
Zaciąłem się i już 2h bez skutku próbuję...
Może ktoś zerknie fachowym okiem co mam nie tak...
Ładnie proszę
Kod działający:
$regfile = "m32def.dat"
$crystal = 16000000
$baud = 19200
Config Serialin = Buffered , Size = 100
Config Porta.0 = Output
Enable Interrupts
Declare Sub Oproznij_bufor
Declare Sub Odczytaj_uart
Declare Sub Odczytaj_sprzetowy_uart
Dim Ringtxt As Byte
Dim Bufor As Byte
Dim Ring As Byte
Dim Kod As String * 100
Dim Dane As String * 200
Dim Stan As Bit
Ringtxt = "RING"
Stan = 0
Waitms 100
Print "ATX0" ; Chr(13) 'Odpowiadaj
Waitms 100
Print "ATZ" ; Chr(13) 'Ustaw domyślnie
Waitms 100
Print "ATE0" ; Chr(13) 'WYLACZ ECHO
Waitms 100
Print "AT+CLIP=1" ; Chr(13) 'Wlaczanie prezentacji numeru
Waitms 100
Set Porta.0
Waitms 100
Reset Porta.0
Waitms 100
Gosub Oproznij_bufor
Do
Call Odczytaj_uart
If Stan = 1 Then Set Porta.0
If Stan = 0 Then Reset Porta.0
Loop
Odczytaj_uart:
Kod = Inkey()
Dane = Dane + Chr(kod)
Bufor = Ischarwaiting()
Ring = Instr(dane , Ringtxt)
If Ring > 0 And Stan = 0 Then
Stan = 1
Wait 1
Print "ATH" ; Chr(13)
Waitms 100
Ring = 0
End If
If Ring > 0 And Stan = 1 Then
Stan = 0
Wait 1
Print "ATH" ; Chr(13)
Waitms 100
Ring = 0
End If
Gosub Oproznij_bufor
Return
Oproznij_bufor:
Do
Kod = Inkey() 'Czyści bufor
Bufor = Ischarwaiting()
Dane = "0"
Loop Until Bufor = 0
Return
Kod nie działający:
$regfile = "m32def.dat"
$crystal = 16000000 '16MHz
$baud = 19200
Config Timer1 = Pwm , Pwm = 8 , Prescale = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
Config Timer2 = Pwm , Async = Off , Compare = Set , Pwm = On , Compare Pwm = Clear Down , Prescale = 8
Config Portb.3 = Output
Set Tccr0.pwm0
Set Tccr0.com00
Set Tccr0.com01
Set Tccr0.cs00
Config Serialin = Buffered , Size = 100
Config Portc.0 = Output
Config Portd.6 = Output
Enable Interrupts
Declare Sub Oproznij_bufor
Declare Sub Odczytaj_uart
Declare Sub Odczytaj_sprzetowy_uart
Declare Sub Swiecenie
Dim Ringtxt As Byte
Dim Bufor As Byte
Dim Ring As Byte
Dim Kod As String * 100
Dim Dane As String * 200
Dim Stan As Bit
Dim T1 As Byte
Dim T2 As Byte
Dim Licznik As Integer
Pk1 Alias Portd.6
Pk2 Alias Portc.0
'zmienne poczatkowe
T1 = 40
T2 = 180
Licznik = 0
Ringtxt = "RING"
Stan = 0
'Inicjacja:
Waitms 100
Print "ATX0" ; Chr(13) 'Odpowiadaj
Waitms 100
Print "ATZ" ; Chr(13) 'Ustaw domyślnie
Waitms 100
Print "ATE0" ; Chr(13) 'WYLACZ ECHO
Waitms 100
Print "AT+CLIP=1" ; Chr(13) 'Wlaczanie prezentacji numeru
Waitms 100
Pk1 = 1
Wait 1
Pwm1a = 255
Ocr0 = 0
Pwm1b = 0
Ocr2 = 0
Waitms 100
itd itp..........
Gosub Oproznij_bufor
'koniec inicjacji
Do
Call Odczytaj_uart
If Stan = 1 Then Call Swiecenie
If Stan = 0 Then Waitms 100
Loop
Swiecenie:
Do
If Licznik < 18 Then Gosub Program1
If Licznik < 8 Then T1 = T1 + 10
If Licznik => 8 And Licznik < 17 Then T1 = T1 - 10
If Licznik => 17 And Licznik < 217 Then Gosub Program2
If Licznik => 17 And Licznik < 117 Then T2 = T2 + 2
If Licznik => 117 And Licznik < 217 Then T2 = T2 - 2
If Licznik = 217 Then T1 = 70
If Licznik => 217 And Licznik < 300 Then Gosub Program1
If Licznik = 300 Then Gosub Zeruj_liczniki
Call Odczytaj_uart
Loop Until Stan = 0
Return
'Obsluga telefonu:
Odczytaj_uart:
Kod = Inkey()
Dane = Dane + Chr(kod)
Bufor = Ischarwaiting()
Ring = Instr(dane , Ringtxt)
If Ring > 0 And Stan = 0 Then
Stan = 1
Wait 1
Print "ATH" ; Chr(13)
Waitms 100
Ring = 0
End If
If Ring > 0 And Stan = 1 Then
Stan = 0
Wait 1
Print "ATH" ; Chr(13)
Waitms 100
Ring = 0
End If
Gosub Oproznij_bufor
Return
Oproznij_bufor:
Do
Kod = Inkey() 'Czyści bufor
Bufor = Ischarwaiting()
Dane = "0"
Loop Until Bufor = 0
Return
'programy swiecenia:
Program1:
Pwm1a = 1
Pwm1b = 255
Ocr0 = 16
Ocr2 = 16
Waitms T1
Pwm1a = 16
Pwm1b = 240
Ocr0 = 10
Ocr2 = 30
itd itp...........
Incr Licznik
Return
Program2:
Ocr0 = 32
Pwm1a = 80
Ocr2 = 160
Pwm1b = 220
Waitms T2
itd itp.........
Incr Licznik
Return
Zeruj_liczniki:
T1 = 40
T2 = 180
Licznik = 0
Return
Zaciąłem się i już 2h bez skutku próbuję...
Może ktoś zerknie fachowym okiem co mam nie tak...
Ładnie proszę