$regfile = "attiny2313.dat"
$crystal = 8000000
Declare Sub Ind
Config Lcdpin = Pin , Db4 = Porta.1 , Db5 = Portd.3 , Db6 = Portd.4 , Db7 = Portd.5 , E = Portd.1 , Rs = Portd.0
Config Lcd = 16 * 2
Cls
Cursor Off Noblink
Config Pind.6 = Input
Config Pind.2 = Input
Config Pina.0 = Input
Config Portb = Output
Dim Sygnal As Byte
Dim Clock As Byte
Dim Sinusp As Byte
Dim Hz As Word
Enable Interrupts
Enable Timer1
Config Timer1 = Timer , Prescale = 1
On Timer1 Bthmod:
Stop Timer1
Plus Alias Pind.2
Minus Alias Pind.6
Gen Alias Pina.0
Const Lcdnoise = "shym "
Const Lcdsaw = "pila "
Const Lcdsquare = "priamoug"
Const Lcdtriangle = "treygol "
Const Lcdsine = "sinus "
Portd.6 = 1
Portd.2 = 1
Porta.0 = 1
Portb = 0
Sygnal = 3
Cls
Cursor Off Noblink
Start Timer1
Lcd Lcdsquare
Lowerline
Lcd "62500 Hz"
Do
If Sygnal = 1 Then Portb = Rnd(255)
If Sygnal = 2 Then Incr Portb
If Sygnal = 3 Then Toggle Portb
If Sygnal = 4 Then
Do
Incr Portb
If Clock ‹› 0 Then Waitms Clock
Loop Until Portb = 255
Do
Decr Portb
If Clock ‹› 0 Then Waitms Clock
Loop Until Portb = 0
End If
If Sygnal = 5 Then Portb = Lookup(sinusp , Sinus) : Incr Sinusp
If Clock ‹› 0 And Sygnal ‹› 4 Then Waitus Clock
Loop
End
Bthmod:
If Minus = 0 And Clock ‹› 0 Then
Clock = Clock - 1
Call Ind
Do
Loop Until Minus = 1
Waitms 10
End If
If Plus = 0 And Clock ‹ 999999 Then
Clock = Clock + 1
Call Ind
Do
Loop Until Plus = 1
Waitms 10
End If
If Gen = 0 Then
Clock = 0
If Sygnal = 5 Then
Sygnal = 1
Else
Incr Sygnal
End If
Locate 1 , 1
If Sygnal = 1 Then Lcd Lcdnoise
If Sygnal = 2 Then Lcd Lcdsaw
If Sygnal = 3 Then Lcd Lcdsquare
If Sygnal = 4 Then Lcd Lcdtriangle
If Sygnal = 5 Then Lcd Lcdsine
Locate 2 , 1
If Sygnal = 3 Then
Lcd "62500 Hz"
Else
Lcd "0 us"
End If
Do
Loop Until Gen = 1
Waitms 50
End If
Return
Sub Ind
Locate 2 , 1
Lcd " "
Locate 2 , 1
If Sygnal = 3 Then
Hz = 1000 / Clock
Hz = Hz / 2
If Clock = 0 Then Hz = 62500
Else
Hz = Clock
End If
Locate 2 , 1
Lcd Hz
End Sub
Sinus:
Data 64 , 65 , 67 , 68 , 70 , 72 , 73 , 75
Data 76 , 78 , 79 , 81 , 82 , 84 , 85 , 87
Data 88 , 90 , 91 , 92 , 94 , 95 , 97 , 98
Data 99 , 100 , 102 , 103 , 104 , 105 , 107 , 108
Data 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116
Data 117 , 118 , 118 , 119 , 120 , 121 , 121 , 122
Data 123 , 123 , 124 , 124 , 125 , 125 , 126 , 126
Data 126 , 127 , 127 , 127 , 127 , 127 , 127 , 127
Data 128 , 127 , 127 , 127 , 127 , 127 , 127 , 127
Data 126 , 126 , 126 , 125 , 125 , 124 , 124 , 123
Data 123 , 122 , 121 , 121 , 120 , 119 , 118 , 118
Data 117 , 116 , 115 , 114 , 113 , 112 , 111 , 110
Data 109 , 108 , 107 , 105 , 104 , 103 , 102 , 100
Data 99 , 98 , 97 , 95 , 94 , 92 , 91 , 90
Data 88 , 87 , 85 , 84 , 82 , 81 , 79 , 78
Data 76 , 75 , 73 , 72 , 70 , 68 , 67 , 65
Data 64 , 62 , 61 , 59 , 58 , 56 , 54 , 53
Data 51 , 50 , 48 , 47 , 45 , 44 , 42 , 41
Data 39 , 38 , 36 , 35 , 34 , 32 , 31 , 30
Data 28 , 27 , 26 , 25 , 23 , 22 , 21 , 20
Data 19 , 18 , 17 , 15 , 14 , 13 , 13 , 12
Data 11 , 10 , 9 , 8 , 8 , 7 , 6 , 5
Data 5 , 4 , 4 , 3 , 3 , 2 , 2 , 2
Data 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0
Data 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1
Data 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4
Data 5 , 5 , 6 , 7 , 8 , 8 , 9 , 10
Data 11 , 12 , 13 , 13 , 14 , 15 , 17 , 18
Data 19 , 20 , 21 , 22 , 23 , 25 , 26 , 27
Data 28 , 30 , 31 , 32 , 34 , 35 , 36 , 38
Data 39 , 41 , 42 , 44 , 45 , 47 , 48 , 50
Data 51 , 53 , 54 , 56 , 58 , 59 , 61 , 62 |