'************* Konfiguracja uC ***************** '*********************************************** $regfile = "attiny13.dat" '$crystal = 16000000 $crystal = 9600000 Config Portb = &B11100111 : Portb = &B11111100 $hwstack = 20 $swstack = 10 $framesize = 25 I1 Alias Pinb.3 I2 Alias Pinb.4 O1 Alias Portb.0 O2 Alias Portb.1 S Alias Portb.2 Config Timer0 = Timer , Prescale = 256 Enable Timer0 : On Timer0 Prztimer0 Enable Interrupts '********** Konfiguracja uC Koniec ************ '****************** Zmienne ******************* '*********************************************** Dim In1 As Bit , In2 As Bit Dim Tryb As Byte , Rezultat As Integer Dim Licz_sw As Byte Dim Impuls As Byte , Stan_wyjsc As Byte Dim F_6ms As Bit Dim Port As Byte '************* Zmienne Koniec **************** '************** Petla glowna ****************** '*********************************************** Do In1 = I1 In2 = I2 Rezultat = 0 Select Case Tryb Case 0: If In1 = 1 And In2 = 1 Then Incr Tryb 'jezeli dwa rozwarte Case 1: If In1 = 1 And In2 = 0 Then Tryb = 2 If In1 = 0 And In2 = 1 Then Tryb = 3 Case 2: If In1 = 0 And In2 = 1 Then Rezultat = 1 Tryb = 0 End If Case 3: If In1 = 1 And In2 = 0 Then Rezultat = -1 Tryb = 0 End If End Select Waitus 100 If Rezultat <> 0 Then If Rezultat = 1 Then Reset O1 Set O2 Else Reset O2 Set O1 End If Reset S End If If F_6ms = 1 Then F_6ms = 0 If O1 = 1 Or O2 = 1 Then Incr Impuls If Impuls = 15 Then Impuls = 0 O1 = 0 O2 = 0 S = 1 End If Else Impuls = 0 End If End If Loop End '************ Petla glowna Koniec ************** '************ Przerwanie timer 0 *************** '*********************************************** Prztimer0: Timer0 = 5 Set F_6ms Return '******** Przerwanie timer 0 Koniec ************