robby-fant
21.04.2007, 13:43
in der beschreibung vom bascom 1.11.8.5 steht ein befehl mit enable adc.
wenn ich den adc-int eingerichtetet habe und compiliere, wird gesagt, das es diesen befehl nicht gibt, wie kann den adc-int den nun einschalten?
unten ist der code
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 19200
Dim Adhi As Byte , Adlow As Byte
Dim Adcergebnis As Word
Dim Zaehler_encoder As Word
Dim Toggle_rad As Byte
Dim Eingabe_encoder As Word
Dim Encoder_l_r As Byte
Dim Text As String * 8
Dim Text1 As String * 8
Dim Text2 As String * 8
Declare Sub Robby_vor_encoder()
Declare Sub Robby_zurueck_encoder()
Declare Sub Robby_links_encoder()
Declare Sub Robby_rechts_encoder()
Declare Sub Adc_einstellen()
On Int1 Int1_int Nosave
Enable Int1
On Adc Adc_encoder Nosave
Enable Adc ' ergibt eine fehlermeldung
Enable Interrupts
Open "comd.3:19200,8,n,1" For Input As #1
Open "comd.7:19200,8,n,1" For Output As #2
Call Adc_einstellen()
Zaehler_encoder = 0
Toggle_rad = 0
Encoder_l_r = 0
Do
Waitms 255
Loop
End
Int1_int:
Disable Int1
Enable Interrupts
Input #1 , Text
Text1 = Left(text , 3)
Text2 = Right(text , 3)
Eingabe_encoder = Val(text2)
If Text1 = "vor" Then
Print "vor"
Call Robby_vor_encoder()
Print "stop"
End If
If Text1 = "zur" Then
Print "zurueck"
Call Robby_zurueck_encoder()
Print "stop"
End If
If Text1 = "lin" Then
Print "links"
Call Robby_links_encoder()
Print "stop"
End If
If Text1 = "rec" Then
Print "rechts"
Call Robby_rechts_encoder()
Print "stop"
End If
Enable Int1
return
Adc_encoder:
If Encoder_l_r = 1 Then
Adlow = Adcl
Adhi = Adch
Adcergebnis = Makeint(adlow , Adhi)
If Adcergebnis > 500 And Toggle_rad = 1 Then
Incr Zaehler_encoder
Toggle_rad = 0
End If
If Adcergebnis < 300 And Toggle_rad = 0 Then
Incr Zaehler_encoder
Toggle_rad = 1
End If
End If
return
Sub Adc_einstellen()
Adcsr.aden = 1
Adcsr.adfr = 1
Adcsr.adie = 1
Adcsr.adsc = 1
Adcsr.adps1 = 1
Adcsr.adps2 = 1
End Sub
Sub Robby_rechts_encoder()
Zaehler_encoder = 0
Admux.mux0 = 1
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_links_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_vor_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_zurueck_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
auch bei diesem original beispielcode meckert der compiler das enable adc nicht erkannt wird :
'--------------------------------------------------------------------
' ADC_INT.BAS
' demonstration of GETADC() function in combintion with the idle mode
' for a better noise immunity
' Getadc() will also work for other AVR chips that have an ADC converter
'--------------------------------------------------------------------
$regfile = "m48def.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 40
$swstack = 8
$framesize = 40
'configure single mode and auto prescaler setting
'The single mode must be used with the GETADC() function
'The prescaler divides the internal clock by 2,4,8,16,32,64 or 128
'Because the ADC needs a clock from 50-200 KHz
'The AUTO feature, will select the highest clockrate possible
Config Adc = Free , Prescaler = Auto , Reference = Internal
'Now give power to the chip
On Adc Adc_isr Nosave
Enable Adc
Enable Interrupts
Dim W As Word , Channel As Byte
Channel = 0
'now read A/D value from channel 0
Do
Channel = 0
'idle will put the micro into sleep.
'an interrupt will wake the micro.
Start Adc
Idle
Stop Adc
Print "Channel " ; Channel ; " value " ; W
Loop
End
Adc_isr:
push r26
push r27
push r24
in r24,sreg
push r24
push r25
W = Getadc(channel)
pop r25
pop r24
!out sreg,r24
pop r24
pop r27
pop r26
Return
wenn ich den adc-int eingerichtetet habe und compiliere, wird gesagt, das es diesen befehl nicht gibt, wie kann den adc-int den nun einschalten?
unten ist der code
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 19200
Dim Adhi As Byte , Adlow As Byte
Dim Adcergebnis As Word
Dim Zaehler_encoder As Word
Dim Toggle_rad As Byte
Dim Eingabe_encoder As Word
Dim Encoder_l_r As Byte
Dim Text As String * 8
Dim Text1 As String * 8
Dim Text2 As String * 8
Declare Sub Robby_vor_encoder()
Declare Sub Robby_zurueck_encoder()
Declare Sub Robby_links_encoder()
Declare Sub Robby_rechts_encoder()
Declare Sub Adc_einstellen()
On Int1 Int1_int Nosave
Enable Int1
On Adc Adc_encoder Nosave
Enable Adc ' ergibt eine fehlermeldung
Enable Interrupts
Open "comd.3:19200,8,n,1" For Input As #1
Open "comd.7:19200,8,n,1" For Output As #2
Call Adc_einstellen()
Zaehler_encoder = 0
Toggle_rad = 0
Encoder_l_r = 0
Do
Waitms 255
Loop
End
Int1_int:
Disable Int1
Enable Interrupts
Input #1 , Text
Text1 = Left(text , 3)
Text2 = Right(text , 3)
Eingabe_encoder = Val(text2)
If Text1 = "vor" Then
Print "vor"
Call Robby_vor_encoder()
Print "stop"
End If
If Text1 = "zur" Then
Print "zurueck"
Call Robby_zurueck_encoder()
Print "stop"
End If
If Text1 = "lin" Then
Print "links"
Call Robby_links_encoder()
Print "stop"
End If
If Text1 = "rec" Then
Print "rechts"
Call Robby_rechts_encoder()
Print "stop"
End If
Enable Int1
return
Adc_encoder:
If Encoder_l_r = 1 Then
Adlow = Adcl
Adhi = Adch
Adcergebnis = Makeint(adlow , Adhi)
If Adcergebnis > 500 And Toggle_rad = 1 Then
Incr Zaehler_encoder
Toggle_rad = 0
End If
If Adcergebnis < 300 And Toggle_rad = 0 Then
Incr Zaehler_encoder
Toggle_rad = 1
End If
End If
return
Sub Adc_einstellen()
Adcsr.aden = 1
Adcsr.adfr = 1
Adcsr.adie = 1
Adcsr.adsc = 1
Adcsr.adps1 = 1
Adcsr.adps2 = 1
End Sub
Sub Robby_rechts_encoder()
Zaehler_encoder = 0
Admux.mux0 = 1
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_links_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_vor_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
Sub Robby_zurueck_encoder()
Zaehler_encoder = 0
Admux.mux0 = 0
Encoder_l_r = 1
While Zaehler_encoder < Eingabe_encoder
Waitms 5
Wend
Encoder_l_r = 0
End Sub
auch bei diesem original beispielcode meckert der compiler das enable adc nicht erkannt wird :
'--------------------------------------------------------------------
' ADC_INT.BAS
' demonstration of GETADC() function in combintion with the idle mode
' for a better noise immunity
' Getadc() will also work for other AVR chips that have an ADC converter
'--------------------------------------------------------------------
$regfile = "m48def.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 40
$swstack = 8
$framesize = 40
'configure single mode and auto prescaler setting
'The single mode must be used with the GETADC() function
'The prescaler divides the internal clock by 2,4,8,16,32,64 or 128
'Because the ADC needs a clock from 50-200 KHz
'The AUTO feature, will select the highest clockrate possible
Config Adc = Free , Prescaler = Auto , Reference = Internal
'Now give power to the chip
On Adc Adc_isr Nosave
Enable Adc
Enable Interrupts
Dim W As Word , Channel As Byte
Channel = 0
'now read A/D value from channel 0
Do
Channel = 0
'idle will put the micro into sleep.
'an interrupt will wake the micro.
Start Adc
Idle
Stop Adc
Print "Channel " ; Channel ; " value " ; W
Loop
End
Adc_isr:
push r26
push r27
push r24
in r24,sreg
push r24
push r25
W = Getadc(channel)
pop r25
pop r24
!out sreg,r24
pop r24
pop r27
pop r26
Return