Hi ich möchte gerne mit Bascom auslesen, was am Uart eintrifft, jedoch kommen immer irgendwelche Fehler (bsp. weis ich net, als was ich die temporäre Variable dimmen soll...) Jetzt ganz einfach habe ich mir gedacht, ob es nicht ein Beispielprog gibt, welches das wieder mit Print ausspuckt, was es empfangen hat. Wenn ja, kann man mir einen Link zu Verfügung stellen? Wenn nicht, sollte es dich ein Wenigzeiler sein, vll. könnte jemand diesen kurz Posten. Ich hoffe dass ich vier nicht totale Basics abfrage und mich zum Affen mache, aber es klappt mit Inkey oder Input einfach nicht :-( Edit: Controller ist ein ATMega 32, Print klappt soweit recht gut...
$regfile = "m161def.dat" ' specify
the used micro
$crystal = 4000000 ' used
crystal frequency
$baud = 9600 ' use baud
rate
$hwstack = 32 ' default
use 32 for the hardware stack
$swstack = 10 ' default
use 10 for the SW stack
$framesize = 40 ' default
use 40 for the frame space
'first compile and run this program with the line below remarked
Config Serialin = Buffered , Size = 20
Dim Na As String * 10
'the enabling of interrupts is not needed for the normal serial mode
'So the line below must be remarked to for the first test
Enable Interrupts
Print "Start"
Do
'get a char from the UART
If Ischarwaiting() = 1 Then 'was there a
char?
Input Na
Print Na 'print it
End If
Wait 1 'wait 1
second
Loop
Ähnlich hab ich jetzt gelöst:
1 | Do |
2 | |
3 | Dim Complete As Bit |
4 | Complete = 1 |
5 | |
6 | Waitms 100 |
7 | Do |
8 | |
9 | |
10 | If Ischarwaiting() = 1 Then |
11 | Bkey = Inkey() |
12 | Ckey = Chr(bkey) |
13 | Akey = Akey + Ckey |
14 | |
15 | Complete = 0 |
16 | |
17 | End If |
18 | |
19 | If Ckey = "!"then |
20 | Print Akey |
21 | Akey = "" |
22 | Ckey = "0" |
23 | Complete = 1 |
24 | End If |
25 | |
26 | Loop Until Complete = 1 |
27 | |
28 | Loop |
wenn das letzte Zeichen ein "!" ist, wird das ganze "geprintet", aber das Problem ist, dass Inkey nur ein Zeichen ist, desshalb "verpasst" der einige Zeichen am Anfang Füge ich vorne
1 | Config Serialin = Buffered , Size = 20 |
an, so kommt gar keine Antwort (und auch gar kein Print) mehr an... Woran könnte das liegen?
du must die ankommenden zeichen mit CHR() in einem string umwandeln
und dann in eine string variable addieren.
DIM Dat As String
Dat = ""
Do
Z = Inkey()
If Z <> 0 Then Dat = Dat + Chr(z)
Loop Until Z = 0
nee, daran lag es nicht (habe ich ja ;-) ) Es lag daran, dass ich Enable Interrupts vergessen habe. Ansich klappt jetzt alles :D Nur eine Function erstellen, die einen String ausgeben soll, klappt nicht (hatte das Problem schonmal :-/ ) Unknown ASM nmemonic
es geht ja, wenn ich es mit integer mache, aber nicht mit string (mein der mag das string "* 16" nicht, klappt aber nicht mit und auch nicht ohne "* 16")
Declare Function mpfange_daten(dat As String) As Byte
Function empfange_daten(dat As String) As Byte
Local Z As Byte
Waitms 20
Dat = ""
Do n
Z = Inkey()
If Z <> 0 Then Dat = Dat + Chr(z)
Loop Until Z = 0
Rn_empfange_funkstring = 0
End Function
nicht ganz, eher so:
Declare Function mpfange_daten(dat As String) As [b]String[/b]
Function empfange_daten(dat As String) As [b]String[/b]
Local Z As Byte
Waitms 20
Dat = ""
Do n
Z = Inkey()
If Z <> 0 Then Dat = Dat + Chr(z)
Loop Until Z = 0
Rn_empfange_funkstring = 0
End Function
das geht nicht funktionen geben meistens nur eine 0 oder 1 zurück aber string wird wohl nicht klappen
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.