czy ten program powinien działać
: 10 gru 2017, 1:21
Witam - czy załączony program będzie działał czy mam coś źle - proszę o podpowiedź.
pozdrawiam Jacek.
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- '************************************************
- 'MIKROKONTROLER
- '$sim
- $regfile = "m16adef.dat"
- $crystal = 16000000
- '$baud = 19200
- $hwstack = 64
- $swstack = 32
- $framesize = 64
- '************************************************
- 'KONFIGURACJA TIMER0
- Config Timer0 = Timer , Prescale = 256
- Enable Timer0 : On Timer0 Przertimer0
- '************************************************
- 'KONFIGURACJA LCD
- Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16
- Config Lcd = 16 * 4
- '************************************************
- 'PRZYPISANIE ZMIENNYCH
- Dim Dzielnik(4) As Byte 'dzielniki timera
- Dim Flaga_4ms As Bit , Flaga_100ms As Bit , Flaga_500ms As Bit , Flaga_1s As Bit , Flaga_5s As Bit 'flagi przerwa?
- Dim Poz_wys As Byte
- '************************************************
- 'DEKLARACJE
- Declare Sub Wyswietlanie
- Declare Sub Przyciski
- 'KONFIGURACJA PORTÓW
- Config Portd = &B00000000 , Portd = &B11111111
- '************************************************
- 'ALIASY
- Enter Alias Pind.0
- '************************************************
- 'USTAWIENIA POCZĄTKOWE
- Cursor Off
- Cls
- Poz_wys = 0
- Locate 1 , 1 : Lcd "poz. lcd zero"
- '************************************************
- 'POCZĄTEK
- Do
- '********************************************** co 4ms
- If Flaga_4ms = 1 Then
- Flaga_4ms = 0
- End If
- '***********************************************
- If Flaga_100ms = 1 Then
- Flaga_100ms = 0
- Call Przyciski
- End If
- '*********************************************** co 500ms
- If Flaga_500ms = 1 Then
- Flaga_500ms = 0
- 'Gosub Wysw
- End If
- '*********************************************** co 1s
- If Flaga_1s = 1 Then
- Flaga_1s = 0
- Call Wyswietlanie
- End If
- '********************************************* co 5s
- Loop
- End
- '************************************************
- 'PRZERWANIE TIMER0
- Przertimer0:
- Timer0 = 6
- Set Flaga_4ms 'wyzawlanie co 4ms
- Incr Dzielnik(1)
- If Dzielnik(1) = 25 Then
- Dzielnik(1) = 0
- Set Flaga_100ms 'wyzwalanie co 100ms
- Incr Dzielnik(2)
- If Dzielnik(2) = 5 Then
- Dzielnik(2) = 0
- Set Flaga_500ms 'wyzwalanie co 500ms
- Incr Dzielnik(3)
- If Dzielnik(3) = 2 Then
- Dzielnik(3) = 0
- Set Flaga_1s 'wyzwalanie co 1s
- Incr Dzielnik(4)
- If Dzielnik(4) = 5 Then
- Dzielnik(4) = 0
- Set Flaga_5s 'wyzwalanie co 5s
- End If
- End If
- End If
- End If
- Return
- Sub Przyciski:
- If Enter = 0 And Flaga_5s = 1 Then
- Flaga_5s = 0
- Poz_wys = 1
- End If
- End Sub
- Sub Wyswietlanie:
- If Poz_wys = 0 Then
- Cls
- Locate 1 , 1 : Lcd "poz. lcd zero "
- If Poz_wys = 1 Then
- Cls
- Locate 1 , 1 : Lcd "poz. lcd jeden "
- End If
- End If
- End Sub