Programmzeile
|
Bemerkung
|
$regfile "m8def.dat"
|
Definiert den Atmega als Atmega 8 |
$crystal = 1000000
|
Gibt die Quarzfrequenz an in Herz |
$hwstack = 32
|
Default use 32 Hardware reservierte Speicher |
$swstack = 10
|
Default Software resvierung Speicher |
| Dim Eprom As Eram Word |
|
| Dim Ram As Word |
|
Dim A As Word
|
Variable für Warteschleife Timer ein / aus schalten |
| Dim Timer_null_wert As Byte |
|
| Dim C As Byte |
|
Dim B As Word
|
Variable für cmpare1A höher oder niedriger |
| Dim Speicherzaehler As Word |
|
| Dim H As Byte |
|
| Dim Aa As Word |
|
Ddrc = &B00111000
|
Port , C.3, C4 , C5 als Ausgänge |
Ddrb = &B00000011
|
PortB.1 als Ausgang setzen |
Portd = &B00001100
|
Pull Up an Portd2 und D3. setzen |
| On Timer0 Timer_null |
|
Timsk.toie0 = 1
|
interrupt für timer0 freigeben |
Sreg.7 = 1
|
Globale Interrupt Freigeben |
Tccr1a = &B01000000
|
Timer 1 Konfiguration |
Tccr1b = &B00001001
|
Takt durch 1048 Teilen |
| Ram = Eprom |
|
| Waitms 50 |
|
| Compare1a = Ram |
|
| Waitms 50 |
|
| H = 10 |
|
| If Pind.2 = 0 Then Goto Wobbel_low |
|
| If Pind.3 = 0 Then Goto Wobbel_high |
|
| Do |
|
Portc.4 = 1
|
Betriebsled Rot einschalten |
| Waitms 10 |
|
| If Pind.2 = 0 Or Pind.3 = 0 Then Portc.5 = 1 Else Portc.5 = 0 |
|
| If Pind.2 = 0 Then Compare1a = Compare1a + B |
|
| If Pind.3 = 0 Then Compare1a = Compare1a - B |
|
If Pind.2 = 0 Or Pind.3 = 0 Then Timer0 = 0
|
Timer 0 auf null setzen |
| If Pind.2 = 0 Or Pind.3 = 0 Then Speicherzaehler = 0 |
|
If Pind.2 = 0 Or Pind.3 = 0 Then Tccr0 = &B00000101
|
Timer 0 wird gestartet |
If Compare1a > 0 Then B = 1
|
Logaritmische Frequenzänderung |
If Compare1a > 40 Then B = 3
|
ausgleichen , anpassen |
| If Compare1a > 100 Then B = 20 |
|
| If Compare1a > 1000 Then B = 50 |
|
| If Compare1a > 1500 Then B = 100 |
|
If Compare1a > 65534 Then Compare1a = 65534
|
verhindert einenÜberlauf |
If Compare1a < 2 Then Compare1a = 2
|
verhindert einen unterlauf |
| Portc.4 = 0 |
|
| Waitms 100 |
|
| Loop |
|
| Abspeichern: |
|
| Ram = Compare1a |
|
| Waitms 50 |
|
| Eprom = Ram |
|
| Waitms 50 |
|
| Return |
|
| Timer_null: |
|
| Incr Speicherzaehler |
|
| If Speicherzaehler > 10 Then Gosub Abspeichern |
|
If Speicherzaehler > 10 Then Tccr0 = &B00000000
|
Timer 0 stoppen |
| Return |
|
| Wobbel_high: |
|
Compare1a = 13
|
35,87 KHz Khz bis 21 KHZ |
| Do |
|
| For Aa = 1 To 12 |
|
| Compare1a = Compare1a + 1 |
|
| Waitms 500 |
|
| Next Aa |
|
| For Aa = 1 To 12 |
|
| Compare1a = Compare1a - 1 |
|
| Waitms 500 |
|
| Next Aa |
|
| Loop |
|
| Wobbel_low: |
|
Compare1a = 25
|
19,3 Khz bis 1 khz |
| Do |
|
| For Aa = 1 To 500 |
|
| Compare1a = Compare1a + 1 |
|
| Waitms 5 |
|
| Next Aa |
|
| For Aa = 1 To 500 |
|
| Compare1a = Compare1a - 1 |
|
| Waitms 5 |
|
| Next Aa |
|
| Loop |
|