Forum: Mikrocontroller und Digitale Elektronik ATM128, Bascom und Serroutprobleme


von Daniel (Gast)


Lesenswert?

Guten Abend,

ich habe da ein kleines Problemchen , eigentlich sinds 2, aber das 2te 
lass ich noch für den moment. Ich möchte gerne über SEROUT Daten 
rausschicken und habe dies mit Port E.0 und D.3 versucht, bei beiden das 
gleiche Ergebniss. Im Terminal kam überhaupt nichts raus, ich hänge euch 
mein Code mal an, syntaktisch sollte der eigentlich stimmen, aber wieso 
das nicht funktioniert weiss ich auch nicht. (kompatibilitätsmodus ist 
auch ausgeschaltet)
1
$regfile = "m128def.dat"
2
$crystal = 16000000
3
Baud = 9600
4
5
Dim Haha As String * 10
6
Goto Test1
7
8
9
Test1:
10
11
Do
12
  Haha = "haha"
13
   Serout Haha , 4 , D , 1 , 9600 , 0 , 8 , 1
14
Loop

Und das 2te Problem trat eigentlich noch früher auf, als das, welches 
ich  oben beschrieben habe. Es ging eigentlich um genau gleiche mit dem 
kleinen Unterschied, das es anstatt des String's ein Array von 4 
Integern war. Fehlermeldung : Array expected, hmmmm.... hab ich ned 
kapiert.. den ein Array hat er ja bekommen.

Definiert war dies folgendermassen
1
Dim Sendbyte(4) As Integer 
2
3
4
'Inhalt von Sendbyte wurde folgendermassen gefüllt
5
    Select Case Cmd
6
           Case 1                                           'Play
7
                Sendbyte(1) = 32
8
                Sendbyte(2) = 01
9
                Sendbyte(3) = 33
10
           Case 2                                           'Stop
11
                Sendbyte(1) = 32
12
                Sendbyte(2) = 00
13
                Sendbyte(3) = 32
14
           Case 3                                           'Rec
15
                Sendbyte(1) = 32
16
                Sendbyte(2) = 02
17
                Sendbyte(3) = 34
18
           Case 4                                           'Fast forward
19
                Sendbyte(1) = 32
20
                Sendbyte(2) = 16
21
                Sendbyte(3) = 48
22
           Case 5                                           'Fast backward
23
               Sendbyte(1) = 32
24
               Sendbyte(2) = 32
25
               Sendbyte(3) = 64
26
           Case 6                                           'Jog forward
27
                Sendbyte(1) = 32
28
                Sendbyte(2) = 01
29
                Sendbyte(3) = Speed
30
                Sendbyte(4) = 33 + Speed
31
           Case 7                                           'Jog backward
32
                Sendbyte(1) = 32
33
                Sendbyte(2) = 01
34
                Sendbyte(3) = Speed
35
                Sendbyte(4) = 33 + Speed

von Paul Baumann (Gast)


Lesenswert?

>habe dies mit Port E.0 und D.3 versucht
Da kommst Du aber nicht raus, sondern auf Port D.1
Der String ist aber nur 4 Zeichen lang und bei Dir ist er auf 10 
dimensioniert. Das "GOTO" brauchst Du da auch nicht, er kommt sowieso 
von allein zu dem Label "Test1"

Versuche mal diese Zeile:

Serout Haha , 0 , E , 0 , 9600 , 0 , 8 , 1

MfG Paul

von Daniel (Gast)


Lesenswert?

Hallo Peter, danke für deine Antwort,

folgendes: die Sache mit der Variabelgrösse habe ich übersehen, die 
Sache mit dem Goto ist gewollt, weil da noch mehrere Übungen hinsollen 
und ich mit diesem goto dann sehr einfach steuern kann wohin das 
programm geht.

Zum Problem:
1
$regfile = "m128def.dat"
2
$crystal = 16000000
3
Baud = 9600
4
5
Dim Haha As String * 4
6
Goto Test1
7
8
9
Test1:
10
11
Do
12
  Haha = "haha"
13
   Serout Haha , 4 , D , 1 , 9600 , 0 , 8 , 1
14
Loop
erzueugt überhaupt keine Ausgabe
1
  Serout Haha , 0 , D , 1 , 9600 , 0 , 8 , 1
2
  Serout Haha , 0 , E , 0 , 9600 , 0 , 8 , 1
3
  Serout Haha , 4 , E , 0 , 9600 , 0 , 8 , 1
4
  Serout Haha , 0 , D , 3 , 9600 , 0 , 8 , 1
5
  Serout Haha , 4 , D , 3 , 9600 , 0 , 8 , 1
diese codezeilen hier erzeugen ebenfalls keine Ausgabe im Terminal

Ich habe nun wirklich alles ausprobiert und vom Datenblatt des Prozesors 
wären ja eigentlich die Ports E1 und D3 di UART-Transmitt Pins. 
Korriegiert mich bitte wenn ich mit meiner Logik eventuell Unsinn 
anrichte. Aber es kann doch nicht sein dass auf allen ausgabepins nix 
kommt.

Grüsse
Daniel

von Weingut P. (weinbauer)


Lesenswert?

wenn du $baud schreibst ists sowieso essig mit
serout auf den uart pins, weil die dann nicht auf
standard I-O sondern auf UART belegt werden.

alternativ kannste mal $baud=9600 und $baud1=9600
setzen und dann per print "haha" und print #1, "duda"
die hardwareuart testen.

dann gibts da noch das problem mit der fuse
m103-compatibility, die sollte deaktiviert sein.

von Ich weis es (Gast)


Lesenswert?

Hast Du von Bascom was anderes erwartet als Probleme?
Nimm eine vernünftige Programmiersprache dann klappt's auch.
BASCOM == Probleme;

von Paul Baumann (Gast)


Lesenswert?

Mal ein paar Sätze aus der Bascom Hilfe zu "Serout":
 String variables will wait for a return (ASCII 13). There is no check 
if the variable you assign is big enough to hold the result.


Serout S , 0 , D , 1 , Mybaud , 0 , 8 , 1

'                                      ^ 1 stop bit

'                                  ^---- 8 data bits

'                                ^------ even parity (0=N, 1 = E, 2=O)

'                        ^-------------- baud rate

'                  ^-------------------- pin number

'               ^----------------------- port so PORTA.0 and PORTA.1 are 
used

'           ^--------------------------- for strings pass 0

'      ^-------------------------------- variable


@Ich weiß es

Nein, Du weißt es nicht! Auch eine sog. "vernünftige" Programmiersprache
gibt nichts auf den "richtigen" Portpin aus, wenn der falsche 
angesprochen wird.

Paul

von Ich weis es (Gast)


Lesenswert?

Was für ein Schotter.
Mir ist schlecht von soviel Bascom.

von dsgfsdfgsdfg (Gast)


Lesenswert?

@ Ich weis es (Gast)

dann halt dich doch aus bascom threads raus ...
was soll denn das unproduktive genöle.
zieh dir dein c doch die nase hoch wenns dich
glücklich macht. ... bei c kommt mir im übrigen
was hoch was ich hier nicht tippen möchte.

von Daniel (Gast)


Lesenswert?

@Paul:

Die Serrouthilfe hab ich mir in meine Bascombuch durchgeschaut und mein 
Befehl eigentlich genau auf dem Beispiel von da zusammengeschraubt. Nur 
verstehe ich nicht wieso da auf der Konsole nichts dabei herauskommt. 
Muss ich da etwa in irgend einem Register noch was umschalten?

Der Kompatibilitätsmodus ist schon lange draussen, alle möglichen 
Ausgabebins habe ich versucht... ich weiss ned weiter

von dsgfsdfgsdfg (Gast)


Lesenswert?

haste denn auch die ddr gesetzt?
also config portx.y = output  ?

könnte mit rein spielen

von Anonymous (Gast)


Lesenswert?

(ATmega128)

The pins PE1 is the TX pin of the first hardware USART.
The pins PD3 is the TX pin of the second hardware USART.

The Bascom SEROUT command is a software UART. There is no
need to use this command if you are using the pins of the
built-in hardware USART.

Try this code and make sure you are using a TTL>RS232 level
shifter like a MAX232 chip.
1
$regfile = "m128def.dat"
2
$crystal = 16000000
3
$baud = 9600
4
5
Do
6
7
   Print "Hello!"  ' Will print from the hardware USART0, pin PE1.
8
   Waitms 1000
9
10
Loop
11
12
End


To use both hardware USARTs, see the Bascom sample "m128.bas"
located in the folder ...BASCOM-AVR\SAMPLES\CHIPS\.

Note that in ATmega103 compatibility mode, the second USART is
not available. (Disable the M103 compatibility mode via fuse bit).

If you still need a software UART, then see the sample "serin_out.bas"
located in the folder ...BASCOM-AVR\SAMPLES\SERIAL\

von Daniel (Gast)


Lesenswert?

My Hero Anonymous :),

Since I began with this Story of Serout Serin UART e.c., i wasnt' as 
close as now by the end then now.

Now my Terminal, at least becomes something from the Board, but every 
time the same crappy shit. Instead of Hello, he prints that funny 
symbols as you can see in the attachment. What could that be?

Thanks for your help
Daniel

von Anonymous (Gast)


Lesenswert?

You are using the wrong clock source. The ATmega128
is shipped with the internal RC oscillator at 1 MHz.
(The chip is shipped with the internal RC oscillator enabled).

Verify the fuse bytes.

If the chip is running at 1 MHz, then try this code:
1
$regfile = "m128def.dat"
2
$crystal = 1000000
3
$baud = 2400
4
5
Do
6
7
   Print "Hello!"  ' Will print from the hardware USART0, pin PE1.
8
   Waitms 1000
9
10
Loop
11
12
End

Remember to change the baud rate of the terminal emulator to 2400.
(9600 not possible at 1MHz).

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
Noch kein Account? Hier anmelden.