- 阅读权限
- 200
- UID
- 2
- 帖子
- 343
- 精华
- 0
- 注册时间
- 2013-2-20
- 在线时间
- 368 小时
- UID
- 2
- 帖子
- 343
- 精华
- 0
- 注册时间
- 2013-2-20
- 在线时间
- 368 小时
|
'在网上看到有一个关于M8控制BH1415的BASCOM程序,编译不能通过,哪位高人能帮忙看看嘛?
$regfile = "m8def.dat" 'M8-Deklarationen
$crystal = 1000000 'interner RC-Oszillator reicht
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portb.1 , Rs = Portb.2
Config Lcd = 16 * 2
Dim Retvalue As Byte
Dim Zahlstr As String * 5
Dim Frequ As Word : Frequ = 961 'Programm-Default-Werte
Dim Stereo As Byte : Stereo = 1 'alles Ein
Dim Driver As Byte : Driver = 1
Dim Licht As Byte : Licht = 1
Dim Dummy_ee As Eram Long 'Werte fürs EEPROM
Dim Frequ_ee As Eram Word
Dim Stereo_ee As Eram Byte
Dim Driver_ee As Eram Byte
Dim Licht_ee As Eram Byte
Dim Menu1(8) As String * 8 'Menüwerte
Menu1(1) = "Frequenz"
Menu1(2) = "Stereo "
Menu1(3) = "Treiber "
Menu1(4) = "Licht "
Menu1(5) = "Sichern "
Menu1(6) = "AbstimmU"
Menu1(7) = "AntenneU"
Menu1(8) = "zurueck "
Dim Menu2(2) As String * 3
Menu2(1) = "Ein"
Menu2(2) = "Aus"
Ddrd.2 = 0 'drehimpuls 1 = INT0
Portd.2 = 1 'Pullup
Ddrb.0 = 0 'drehimpuls 2
Portb.0 = 1 'Pullup
Ddrd.3 = 0 'Set-Button = INT1
Portd.3 = 1 'Pull-Up
Setbutton Alias Pind.3 'Menübest?tigungs-Knopf
Dim Drehgeber As Word 'wird von ISR (INT0) ver?ndert
On Int0 Onint0
Mcucr.isc00 = 1 'INT0 bei FALLING + RISING
Mcucr.isc01 = 0
Gicr.int0 = 1
Config Int1 = Low Level 'nur zum Aufwachen aus Sleep-Modus
On Int1 Onint1
Mcucr.sm1 = 1
Mcucr.se = 1 'Sleep-Modus=Power-Down
Ddrd.4 = 1 'PD4= "Licht"
Ddrd.5 = 1 'PD5= Ausgang zum IC-PLL (Data)
Datas Alias Portd.5
Ddrd.6 = 1 'PD6= Clock
Clock Alias Portd.6
Ddrd.7 = 1 'PD7= Chip Enable
Chipena Alias Portd.7
Admux.refs0 = 1 'ADC-Config:
Admux.refs1 = 1 'interne Referenz
Adcsr.adps0 = 1
Adcsr.adps1 = 1
Adcsr.adps2 = 1 'Prescaler=128
Adcsr.aden = 1 'ADC einschalten
Ddrc.0 = 0 'als Eing?nge schalten (ADC0-1)
Ddrc.1 = 0
Sreg.7 = 1 'alle Interrupts freigeben
Declare Function Menu(menuitems() As String , Byval Maxentry As Byte , Byval Default As Byte ) As Byte
Declare Function Frequenz(byval Default As Word) As Word
Declare Sub Toic_pll
Declare Sub Showadc(byval Anz_mod As Byte)
If Frequ_ee <> &HFFFF Then 'abgespeicherte Default-Werte
Frequ = Frequ_ee
Stereo = Stereo_ee
Driver = Driver_ee
Licht = Licht_ee
End If
Portd.4 = Not Licht.0 'Display-Licht; LOW-Aktiv
Toic_pll ' schiebt frequ, stereo u. driver i.d. Chip
Cls
Locate 2 , 1
Lcd "PLL SENDER"
Do
Cursor Off
Locate 1 , 1 : Lcd Menu1(1)
Locate 1 , 10 : Zahlstr = Str(frequ) : Zahlstr = Format(zahlstr , " 00.0") : Lcd Zahlstr ; Spc(2)
Enable Int1
!sleep 'nur Druck (LOW LEVEL-Int) weckt auf
Disable Int1
Waitms 500
Locate 1 , 10 : Lcd Spc(6)
Cursor On Blink
Do
Locate 1 , 1
Retvalue = Menu(menu1(1) , 8 , 1)
Locate 1 , 10
Select Case Retvalue
Case 1 : Frequ = Frequenz(frequ)
Exit Do
Case 2 : Stereo = Menu(menu2(1) , 2 , Stereo)
Exit Do
Case 3 : Driver = Menu(menu2(1) , 2 , Driver)
Exit Do
Case 4 : Licht = Menu(menu2(1) , 2 , Licht)
Portd.4 = Not Licht.0 'Low-Aktiv
Goto Loopend
Case 5 : Sreg.7 = 0 'zum Abspeichern INTs abschalten
Frequ_ee = Frequ
Stereo_ee = Stereo
Driver_ee = Driver
Licht_ee = Licht
Sreg.7 = 1
Goto Loopend
Case 6 : Admux.0 = 0 'ADC-Kanal 0
Call Showadc(0)
Goto Loopend2
Case 7 : Admux.0 = 1 'ADC-Kanal 1
Call Showadc(1)
Goto Loopend2
Case 8 : Goto Loopend2
End Select
Loop
Call Toic_pll
Loopend:
Locate 1 , 10 : Lcd "ok" ; Spc(3)
Wait 1
Loopend2:
Loop
End
Function Menu(menuitems() As String , Byval Maxentry As Byte , Byval Default As Byte ) As Byte
Local Curent As Byte
Local Mlen As Byte
Local Drehgeber_alt As Word
Local Lauf As Byte
Drehgeber = &H8000
Drehgeber_alt = &H8000
Mlen = Len(menuitems(1))
Lcd Menuitems(default);
Curent = Default
Do
If Setbutton = 0 Then
Menu = Curent
Waitms 500
Exit Function
End If
If Drehgeber <> Drehgeber_alt Then
If Drehgeber > Drehgeber_alt Then
Incr Curent
If Curent > Maxentry Then
Curent = 1
End If
End If
If Drehgeber < Drehgeber_alt Then
Decr Curent
If Curent = 0 Then
Curent = Maxentry
End If
End If
For Lauf = 1 To Mlen
Shiftcursor Left
Next Lauf
Lcd Menuitems(curent);
Drehgeber_alt = Drehgeber
End If
Loop
End Function
Function Frequenz(byval Default As Word) As Word
Local S As String * 5
Local Drehgeber_alt As Word
Local Lauf As Byte
Drehgeber = Default
Drehgeber_alt = Drehgeber
S = Str(drehgeber)
S = Format(s , " 00.0" )
Lcd S
Do
If Drehgeber <> Drehgeber_alt Then
If Drehgeber > 1080 Then
Drehgeber = 875
End If
If Drehgeber < 875 Then
Drehgeber = 1080
End If
Drehgeber_alt = Drehgeber
For Lauf = 1 To 5
Shiftcursor Left
Next Lauf
S = Str(drehgeber_alt)
S = Format(s , " 00.0" )
Lcd S
End If
If Setbutton = 0 Then
Frequenz = Drehgeber_alt
Waitms 500
Exit Function
End If
Loop
End Function
Sub Toic_pll
Local Seriellword As Word
Local Lauf As Byte
Seriellword = Frequ
Seriellword.11 = Stereo.0
Seriellword.14 = Driver.0
'locate 2 , 1
'lcd bin(seriellword )
Chipena = 1 'Chip selektieren
For Lauf = 1 To 16
Datas = Seriellword.0 'Datenbit 0 anlegen
Clock = 1 'und übergeben
Waitus 250
Clock = 0
Shift Seriellword , Right 'n?chstes Bit in Position 0 schieben
Next Lauf 'Chip deselektieren
Chipena = 0
End Sub
Sub Showadc(byval Anz_mod As Byte)
Local Adc_h As Word
Local Adc_val As Word '10 bit
Adcsr.adfr = 1 'free running
Adcsr.adsc = 1 'starten
Cursor Noblink
Cursor Off
Do
Adc_val = Adcl
Adc_h = Adch
Shift Adc_h , Left , 8
Adc_val = Adc_val Or Adc_h
Locate 1 , 10
Select Case Anz_mod
Case 0 : Zahlstr = Str(adc_val) 'Abstimmspannung (V)
Zahlstr = Format(zahlstr , " 0.00")
Lcd Zahlstr ; " V"
Case 1 : Zahlstr = Str(adc_val) 'Antennenspannung (mV)
Zahlstr = Format(zahlstr , " 0")
Lcd Zahlstr ; " "
End Select
Waitms 100
Loop Until Setbutton = 0
Adcsr.adsc = 0
Adcsr.adfr = 0 'free running aus
Locate 1 , 10
Waitms 500
End Sub
Drehimpuls1 Alias Pind.2
Drehimpuls2 Alias Pinb.0
Onint0:
If Drehimpuls1 = 1 Then 'steigende Flanke
If Drehimpuls2 = 1 Then
Decr Drehgeber
Else
Incr Drehgeber
End If
Else 'fallende Flanke
If Drehimpuls2 = 0 Then
Decr Drehgeber
Else
Incr Drehgeber
End If
End If
Return
Onint1: 'nur zum Aufwachen!
Return
|
|