Using the UART/de

From MCS Wiki AVR
< Using the UART(Difference between revisions)
Jump to: navigation, search
 
(SOFTWARE UART)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== (**COPIED FROM ENGLISH PAGE**) === <span class="f_Header">UART</span> =
+
= <span class="f_Header">UART</span> =
  
A Universal Asynchronous Receiver and Transmitter (UART) can be used to send and receive data between two devices. More specific these devices can be PC-to-PC, PC-to-micro controller and micro controller-to-micro controller. The UART communicates using TTL voltages +5V and 0V or LVTTL depending on your micro controllers VCC voltage.
+
Ein Universal Asynchronous Receiver and Transmitter (UART) kann benutzt werden um Daten zwischen zwei Geräten zu senden und zu empfangen. Diese zwei Geräte können sein: PC-zu-PC, PC-zu-Mikrocontroller oder Mikrocontroller-zu-Mikrocontroller. Die UART Kommunikation benutzt TTL Spannungen von +5V and 0V oder LVTTL abhängig von der Mikrocontroller Betriebsspannung.
  
 
&nbsp;
 
&nbsp;
  
If you wish to connect to a PC you need to use RS232 protocol specifications. This means that the hardware communication is done with specific voltage levels. (+15V and -15V) This can be achieved by using a MAX232 level shifter.
+
Wenn eine Verbindung zum PC gewünscht wird dann muss das RS232-Protokoll verwendet werden. Das bedeutet, dass mit definierten Spannungen (+15V und -15V) kommuniziert werden muss. Die kann mit einem MAX232 Level-Shifter erreicht werden.
  
 
&nbsp;
 
&nbsp;
  
The hardware is explained in this schematic:
+
Die Hardware wird im folgenden Schaltplan dargestellt:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 17: Line 17:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The DB-9 connector has 9 pins but you only need to use 3 of them. Notice that the drawing above shows the FRONT VIEW thus remember that you are soldering on the other side. On most connectors the pin outs can also be found on the connector itself.
+
Der DB-9 Anschluss hat 9 Pins aber es müsse nur 3 davon benutzt werden. Die obige Grafik zeigt die Vorderansicht - gelötet wird auf der anderen Seite. Bei den meisten Anschlüssen sind die Pinbezeichnungen auch auf den Steckern und Buchsen selbst zu lesen.
  
 
&nbsp;
 
&nbsp;
  
If your controller has no UART you can use a software UART see below. If your controller has one UART you connect controller pins TxD and RxD to TxD and RxD in the schematic above. If your controller has more than one UART you connect controller pins TxD0 and RxD0 to TxD and RxD in the schematic above.
+
Wenn der verwendete Mikrocontroller HW-UART nicht unterstützt dann kann auch Software-UART benutzt werden. Siehe unten. Wenn der Mikrocontroller einen HW-UART unterstützt dann werden die TxD und RxD Pins mit TxD und RxD im Schaltplan verbunden. Wenn der Mikrocontroller mehrere HW-UARTs hat dann werden die TxD0 und RxD0 Pins mit TxD und RxD entsprechend obigem Schaltplan verbunden.
  
You now need to initialize the program in your micro controller, open a new .bas file and add the following code in the beginning of your program.
+
Nun muss per Programm der Mikrocontroller initialisiert werden. Öffnen Sie dazu eine neue .bas Datei und fügen Sie die folgenden Programmzeilen am Anfang hinzu.
  
 
&nbsp;
 
&nbsp;
  
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"your micro here def.dat"</span>
+
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"verwendeter_mikrocontroller def.dat"</span>
  
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;8000000</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;8000000</span>
Line 35: Line 35:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Make sure to define your micro controller after $regfile for example if you use the ATMega32
+
Stellen Sie sicher, dass der benutzte Mikrocontroller mit $regfile angegeben wird - zum Beispiel der ATMega32
  
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"m32def.dat"</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"m32def.dat"</span>
Line 41: Line 41:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Some new chips can use an internal oscillator, also some chips are configured to use the internal oscillator by default. Using an internal oscillator means you do not need an external crystal.
+
Einige Mikrocontroller können einen internen Oszillator als Taktquelle verwenden. Einige Mikrocontroller verwenden den internen Oszillator standardmäßig. Bei Benutzung eines internen Oszillators braucht man keinen (externen) Quarz.
  
 
&nbsp;
 
&nbsp;
  
<span style="font-family: Arial; font-weight: bold; color: rgb(255, 0, 0); text-decoration: underline;">Perform this step only if you have an internal oscillator.</span>
+
<span style="font-family: Arial; font-weight: bold; color: rgb(255, 0, 0); text-decoration: underline;">Führen Sie diesen Schritt nur aus wenn Sie einen internen Oszillator verwenden.</span>
  
Open the BASCOM-AVR programmer like this:
+
Öffnen Sie den BASCOM-AVR Programmer wie folgt:
  
  
Line 58: Line 58:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Select the “Lock and Fuse Bits” tab and maximize the programmer window.
+
| Wählen Sie den “Lock and Fuse Bits” Tab aus und and maximimieren Sie das Programmer-Fenster.
 
|}
 
|}
 
</div><div style="padding: 0px; margin: 0px -84px 0px 11px;">
 
</div><div style="padding: 0px; margin: 0px -84px 0px 11px;">
Line 64: Line 64:
 
|- valign="baseline" style="vertical-align: baseline;"
 
|- valign="baseline" style="vertical-align: baseline;"
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
 
| width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span>
| Check if you see the following in the “Fusebit” section:
+
| Prüfen Sie, ob Sie den folgenden “Fusebit” Abschnitt sehen:
 
|}
 
|}
 
</div>
 
</div>
 
&nbsp; "1:Divide Clock by 8 Disabled"
 
&nbsp; "1:Divide Clock by 8 Disabled"
  
&nbsp; and
+
&nbsp; und
  
 
&nbsp; &nbsp; &nbsp; &nbsp; "Int. RC Osc. 8 MHz; Start-up time: X CK + X ms; [CKSEL=XXXX SUT=XX]"
 
&nbsp; &nbsp; &nbsp; &nbsp; "Int. RC Osc. 8 MHz; Start-up time: X CK + X ms; [CKSEL=XXXX SUT=XX]"
Line 79: Line 79:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
These options are not available for all AVR’s, if you don’t have the option do not change any fuse bits.
+
Diese Einstellungen gibt es nicht bei jedem AVR Mikrocontroller. Wenn Sie die Einträge bei sich nicht haben dann ändern Sie nicht irgendwelche Fuse Bits.
 +
 
  
 
&nbsp;
 
&nbsp;
  
If these options are available, but in a wrong setting. Change the setting in the drop down box and click another Fuse section. Finally click the "Program FS" &nbsp;button. Click "Refresh" to see the actual setting.
+
Wenn diese Einstellungen verfügbar sind aber mit anderen Werten dann ändern Sie die Werte durch die Drop Down Möglichkeiten. Schließlich klicken Sie den "Program FS" Knopf und dann "Refresh" um die tatsächlichen Einstellungen zu sehen.
  
 
&nbsp;
 
&nbsp;
  
Now connect a straight cable between the DB-9 connector, micro controller side and the PC side.
+
Verbinden Sie nun Mikrocontroller und PC mit einem Kabel mit DB-9 Anschluss
 +
 
 +
Schreiben Sie ein Testprogramm für Ihren Mikrocontroller welches folgendermaßen aussehen sollte:
  
Program a test program into your micro controller, it should look like this:
 
  
 
&nbsp;
 
&nbsp;
  
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"m32def.dat"</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 0);">'Define your own</span>
+
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"m32def.dat"</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 0);">'Verwendeter Mikrocontroller</span>
  
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;8000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-family: Courier;">&nbsp;8000000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>
Line 103: Line 105:
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Do</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Do</span>
  
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;Print</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"Hello World"</span>
+
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;Print</span><span style="font-family: Courier;">&nbsp;</span><span style="font-family: Courier; color: rgb(0, 128, 128);">"Hallo Welt"</span>
  
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitms</span><span style="font-family: Courier;">&nbsp;25</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitms</span><span style="font-family: Courier;">&nbsp;25</span>
Line 115: Line 117:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Now open the BASCOM-AVR Terminal and set your connection settings by clicking “Terminal” -> “Settings” Select your computers COM port and select baud 19200, Parity none, Data bits 8, Stop bits 1, Handshake none, emulation none.
+
Öffnen Sie nun Das BASCOM Terminal-Programm und stellen Sie die Verbindungseinstellungen unter “Terminal” -> “Settings” ein. Wählen Sie den Com-Port wie am PC und stellen Sie eine Baudrate ein von 19200, Parity none, Data bits 8, Stop bits 1, Handshake none, emulation none.
  
 
&nbsp;
 
&nbsp;
Line 123: Line 125:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
If you see the Hello World displayed in the BASCOM-AVR Terminal emulator window, your configuration is OK. Congratulations.
+
Wenn Sie das "Hallo Welt" im BASCOM Terminal Emulator Fenster angezeigt bekommen dann ist alles in Ordnung.
  
 
&nbsp;
 
&nbsp;
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel</span> =
  
You can also try this example with the BASCOM Terminal emulator, it shows you how to send and receive with various commands.
+
Sie können auch das folgende Programm mit dem BASCOM Terminal Emulator ausprobieren welches verschiedene Sende- und Empfangs-Befehle demonstriert.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 141: Line 143:
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Akey&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Here&nbsp;we&nbsp;declare&nbsp;a&nbsp;byte&nbsp;variable</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Akey&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Bytevariable deklarieren</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 147: Line 149:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Hello,&nbsp;hit&nbsp;any&nbsp;alphanumerical&nbsp;key..."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Hallo, geben Sie irgendein alphanumerisches Zeichen ein.."</span>
  
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Waitkey&nbsp;waits&nbsp;untill&nbsp;a&nbsp;char&nbsp;is&nbsp;received&nbsp;from&nbsp;the&nbsp;UART</span>
+
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Waitkey wartet bis ein Zeichen von der UART empfangen wird</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;Akey</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;Akey</span>
Line 159: Line 161:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Thanks!,&nbsp;as&nbsp;you&nbsp;could&nbsp;see&nbsp;the&nbsp;controller&nbsp;prints&nbsp;a&nbsp;number"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Danke! Wie Sie sehen gibt der Mikrocontroller eine Zahl aus."</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"but&nbsp;not&nbsp;the&nbsp;key&nbsp;you&nbsp;pressed."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"aber nicht das getippte Zeichen."</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 169: Line 171:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Now&nbsp;try&nbsp;the&nbsp;enter&nbsp;key..."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Probieren Sie nun die Enter-Taste.."</span>
  
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
Line 181: Line 183:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"The&nbsp;number&nbsp;you&nbsp;see&nbsp;is&nbsp;the&nbsp;ASCII&nbsp;value&nbsp;of&nbsp;the&nbsp;key&nbsp;you&nbsp;pressed."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Die Zahl die Sie sehen ist der ASCII-Wert des eingetippten Zeichens."</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"We&nbsp;need&nbsp;to&nbsp;convert&nbsp;the&nbsp;number&nbsp;back&nbsp;to&nbsp;the&nbsp;key..."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Wir müssen die Zahl wieder zurück umwandeln in das eingetippte Zeichen..."</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Notice&nbsp;what&nbsp;this&nbsp;line&nbsp;does</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Beachten Sie die Funktion dieser Zeile..</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Please&nbsp;try&nbsp;an&nbsp;alphanumerical&nbsp;key&nbsp;again..."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Geben Sie wieder ein alphanumerisches Zeichen ein..."</span>
  
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">akey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Notice&nbsp;what&nbsp;this&nbsp;does</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">akey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Beachten Sie was hier passiert</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"That's&nbsp;fine!"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Jetzt klappt es!"</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 201: Line 203:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"For&nbsp;a&nbsp;lot&nbsp;of&nbsp;functions,&nbsp;just&nbsp;one&nbsp;key&nbsp;is&nbsp;not&nbsp;enough..."</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"In vielen Situationen reicht ein Tastendruck nicht aus..."</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Now&nbsp;type&nbsp;your&nbsp;name&nbsp;and&nbsp;hit&nbsp;enter&nbsp;to&nbsp;confirm"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Geben Sie nun Ihren Namen ein und dann Enter zum Bestätigen"</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">*</span><span style="font-family: 'Courier New';">&nbsp;12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Declare&nbsp;a&nbsp;string&nbsp;variable&nbsp;here</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">String</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">*</span><span style="font-family: 'Courier New';">&nbsp;12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Zeichenkettenvariable deklarieren</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 217: Line 219:
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: 'Courier New';">Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;13&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Goto</span><span style="font-family: 'Courier New';">&nbsp;Thanks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'On&nbsp;enter&nbsp;key&nbsp;goto&nbsp;thanks</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;Akey&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;13&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Goto</span><span style="font-family: 'Courier New';">&nbsp;Thanks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Bei Enter zu thanks springen</span>
  
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">+</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">akey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Assign&nbsp;the&nbsp;string</span>
+
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">+</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">akey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Zeichen an Zeichenkette anhängen/span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span>
Line 227: Line 229:
 
<span style="font-family: 'Courier New';">Thanks</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">:</span>
 
<span style="font-family: 'Courier New';">Thanks</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">:</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Thank&nbsp;you&nbsp;"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"&nbsp;!"</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Notice&nbsp;what&nbsp;;&nbsp;does</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Vielen Dank"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'Courier New';">&nbsp;Inputstring&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"&nbsp;!"</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Beachten Sie die Funktion des Semikolons ; für mehrere Parameter</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 235: Line 237:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Take&nbsp;a&nbsp;look&nbsp;at&nbsp;the&nbsp;program&nbsp;code&nbsp;and&nbsp;try&nbsp;to&nbsp;understand"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Sehen Sie sich den Programm-Code an und versuchen Sie zu verstehen,"</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"how&nbsp;this&nbsp;program&nbsp;works.&nbsp;Also&nbsp;press&nbsp;F1&nbsp;at&nbsp;the&nbsp;statements"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"wie das Programm arbeitet. Drücken Sie auch F1 während die Schreibmarke auf einem Befehl steht."</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"If&nbsp;you&nbsp;understand&nbsp;everything&nbsp;continue&nbsp;to&nbsp;the&nbsp;next&nbsp;experiment"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Wenn Sie alles verstanden haben dann gehen Sie weiter zum nächsten Beispielprogramm."</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 251: Line 253:
 
= <span class="f_Header">ASCII</span> =
 
= <span class="f_Header">ASCII</span> =
  
As you could have seen in the previous example we use the PRINT statement to send something to the UART. Actually we do not send just text. We send ASCII characters. ASCII means American Standard Code for Information Interchange. Basically ASCII is a list of 127 characters.
+
Wie Sie im vorigen Beispiel gesehen haben benutzen wir den PRINT Befehl um irgendetwas zur UART zu senden. Genaugenommen senden wir nicht einfach Text sondern wir senden ASCII-Zeichen. ASCII heißt American Standard Code for Information Interchange. ASCII ist eine Tabelle mit 127 Zeichen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-family: 'Courier New';">ASCII Table (Incomplete)</span>
+
<span style="font-family: 'Courier New';">ASCII Tabelle (unvollständig)</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-family: 'Courier New';">Decimal &nbsp;Hex &nbsp; &nbsp;Binary &nbsp; &nbsp; Value</span>
+
<span style="font-family: 'Courier New';">Dezimal &nbsp;Hex &nbsp; &nbsp;Binär &nbsp; &nbsp; Wert</span>
  
 
<span style="font-family: 'Courier New';">------- &nbsp;--- &nbsp; &nbsp;------ &nbsp; &nbsp; -----</span>
 
<span style="font-family: 'Courier New';">------- &nbsp;--- &nbsp; &nbsp;------ &nbsp; &nbsp; -----</span>
Line 289: Line 291:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can find a complete ASCII table&nbsp;[[ASCII_chart|here]]
+
Die vollständige ASCII Tabelle finden Sie&nbsp;[[ASCII_chart|hier]]
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">CARRIAGE RETURN (CR) AND LINE FEED (LF)</span> =
+
= <span class="f_Header">CARRIAGE RETURN (CR) UND LINE FEED (LF)</span> =
  
In the previous example you can also see that a second print statement always prints the printed text to the following line. This is caused by the fact that the print statement always adds the CR and LF characters.
+
Im vorigen Beispiel konnten Sie auch sehen, dass ein weiterer PRINT Befehl den Text in die nächste Zeile schreibt. Das kommt dadurch, dass der PRINT Befehl immer auch die CR und LF Zeichen anhängt uns ausgibt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Basically if we state:
+
Wenn wir schreiben:
  
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span>
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span>
  
We send 65 66 67 13 10 to the UART. (In binary format)
+
dann senden wir 65 66 67 13 10 to the UART. (Im Binär-Format)
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The carriage return character (13) returns the cursor back to column position 0 of the current line. The line feed (10) moves the cursor to the next line.
+
Das Carriage Return Zeichen (13) bewegt die Schreibmarke zurück zur Position 0 der aktuellen Zeile. Das line feed (10) bewegt die Schreibmarke in die nächste Zeile.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 313: Line 315:
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">;</span>
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">;</span>
  
When we type a semicolon (&nbsp;; ) at the end of the line...
+
Wenn wir ein Semikolon (;) am Ende der Zeile benutzen ...
  
Bascom does not send a carriage return/line feed, so you can print another text after the ABC on the same line.
+
sendet BASCOM kein carriage return/line feed so dass man weiteren Text nach dem ABC auf der selben Zeile schreiben kann.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 321: Line 323:
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'MS Reference Sans Serif';">13</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">)&nbsp;;</span>
 
<span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(0, 128, 128);">“ABC”</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">;</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold;">&nbsp;</span><span style="font-family: 'MS Reference Sans Serif'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'MS Reference Sans Serif';">13</span><span style="font-family: 'MS Reference Sans Serif'; color: rgb(255, 0, 0);">)&nbsp;;</span>
  
This would send only ABC CR. The next print would overwrite the ABC.
+
Das würde nur ABC CR senden. Der nachfolgende Text würde das ABC überschreiben.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">OVERVIEW</span> =
+
= <span class="f_Header">Übersicht</span> =
  
Here are some other commands that you can use for UART communications:
+
Hier finden Sie einige Befehle, die in Zusammenhang mit UART-Kommunikation benutzt werden können:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 333: Line 335:
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Waitkey</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
  
Waitkey will until a character is received in the serial buffer.
+
Waitkey wartet bis ein Zeichen im seriellen Puffer empfangen wird.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 339: Line 341:
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Ischarwaiting</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Ischarwaiting</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
  
Returns 1 when a character is waiting in the hardware UART buffer.
+
Gibt eine 1 zurück wenn ein Zeichen im Hardware UART Puffer ansteht.
  
 
&nbsp;
 
&nbsp;
Line 345: Line 347:
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Inkey</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Inkey</span><span style="font-family: Courier; color: rgb(255, 0, 0);">()</span>
  
Inkey returns the ASCII value of the first character in the serial input buffer.
+
Inkey gibt den ASCII-Wert des ersten Zeichens aus dem seriellen Eingabe-Puffer zurück.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 351: Line 353:
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
 
<span style="font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Print</span>
  
Sends a variable or non-variable string to the UART
+
Sendet eine variable oder eine konstante Zeichenkette zum UART.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 359: Line 361:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">ANOTHER EXAMPLE</span> =
+
= <span class="f_Header">Ein weiiteres Beispiel</span> =
 +
 
 +
Dieses Beispiel zeigt wie Ischarwaiting verwendet wird um zu prüfen ob eine Taste gedrückt wurde. Falls dies der Fall ist wird die Taste in eine Variable eingelesen:
  
This example shows how to use Ischarwaiting to test if there is a key pressed. And if there is, read to a variable.
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Print "Press B key to start"</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Print "Tippen Sie die Taste B um zu starten"</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Serialchar&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Dim</span><span style="font-family: 'Courier New';">&nbsp;Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;Serialchar&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Byte</span>
Line 371: Line 374:
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New';">Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Ischarwaiting</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Check if B or b pressed then goto</span>
+
<span style="font-family: 'Courier New';">Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Ischarwaiting</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">()</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Prüfen, ob B oder b gedrückt wurde. Dann goto</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;1&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;Serialcharwaiting&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;1&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span>
Line 393: Line 396:
 
<span style="font-family: 'Courier New';">Myroutine:</span>
 
<span style="font-family: 'Courier New';">Myroutine:</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Statements</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Anweisungen</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
Line 399: Line 402:
 
<span style="font-family: 'Courier New';">Main:</span>
 
<span style="font-family: 'Courier New';">Main:</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Statements</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Anweisungen</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span>
Line 409: Line 412:
 
= <span class="f_Header">BUFFERING SERIAL DATA</span> =
 
= <span class="f_Header">BUFFERING SERIAL DATA</span> =
  
If you wish to send and receive data at high speed, you need to use serial input and serial output buffers. This buffering is implemented in BASCOM-AVR and can only be used for hardware UART’s.
+
Wenn Sie mit hoher Geschwindigkeit senden und empfangen wollen dann müssen Sie serielle Input und serielle Output Puffer verwenden. Das Puffern wurde in BASCOM implementiert und kann nur mit Hardware UARTs verwendet werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
To configure a UART to use buffers, you need to use the Config statement.
+
Um einen UART für Pufferung zu konfigurieren muss der CONFIG Befehl benutzt werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 419: Line 422:
 
<span style="font-weight: bold; color: rgb(0, 0, 129);">Config&nbsp;</span>Serialout&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>Buffered&nbsp;<span style="color: rgb(255, 0, 0);">,&nbsp;</span>Size&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>20
 
<span style="font-weight: bold; color: rgb(0, 0, 129);">Config&nbsp;</span>Serialout&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>Buffered&nbsp;<span style="color: rgb(255, 0, 0);">,&nbsp;</span>Size&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>20
  
and/or
+
und/oder
  
 
<span style="font-weight: bold; color: rgb(0, 0, 129);">Config&nbsp;</span>Serialin&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>Buffered&nbsp;<span style="color: rgb(255, 0, 0);">,&nbsp;</span>Size&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>20
 
<span style="font-weight: bold; color: rgb(0, 0, 129);">Config&nbsp;</span>Serialin&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>Buffered&nbsp;<span style="color: rgb(255, 0, 0);">,&nbsp;</span>Size&nbsp;<span style="color: rgb(255, 0, 0);">=&nbsp;</span>20
Line 425: Line 428:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
More information can be found in BASCOM-Help. Search topic = "[[CONFIG_SERIALIN|config serialin"]]. There is also a sample program “RS232BUFFER.BAS” in the samples folder if you wish a demonstration of the buffering.
+
Mehr Informationen finden Sie in der BASCOM-Hilfe. Suchen Sie nach  "[[CONFIG_SERIALIN|config serialin"]]. Es gibt auch ein Beispielprogramm  “RS232BUFFER.BAS” im Samples-Verzeichnis.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 433: Line 436:
 
= <span class="f_Header">SOFTWARE UART</span> =
 
= <span class="f_Header">SOFTWARE UART</span> =
  
The previous examples used the hardware UART. That means the compiler uses the internal UART registers and internal hardware (RxD(0) and TxD(0)) of the AVR. If you don’t have a hardware UART you can also use a software UART.
+
Die bisherigen Beispiele benutzen die Hardware UART. Das bedeutet, dass die internen UART Register und interne Hardware (RxD(0) and TxD(0)) des AVR genutzt werden. Wenn Sie keinen Hardware UART haben dann können Sie auch Software UART benutzen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The Bascom compiler makes it easy to “create” additional UART’s. Bascom creates software UART’s on virtually every port pin. &nbsp;
+
Der BASCOM Compiler macht es leicht, weitere UARTS zu definieren. BASCOM kann fast jeden Pin für Software UARTs benutzen.
 +
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Remember that a software UART is not as robust as a hardware UART, thus you can get timing problems if you have lots of interrupts in your program.
+
Bedenken Sie, dass Software UART nicht so stabil ist wie Hardware UART und deshalb kann man Timing-Probleme bekommen wenn viele Interrupts im Programm benutzt werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For this example we use micro controller pins portc.1 and portc.2.
+
Für dieses Beispiel benutzen wir die Pins portc.1 und portc.2.
  
Connect portc.1 to TxD and portc.2 to RxD see the schematic above.
+
Verbinden Sie portc.1 mit TxD und portc.2 mit RxD entsprechend obigem Schaltplan.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Change the $regfile and program this example:
+
Ändern Sie $regfile und programmieren Sie dieses Beispiel:
  
 
<span style="font-size: 12pt; font-family: Arial;">&nbsp;</span>
 
<span style="font-size: 12pt; font-family: Arial;">&nbsp;</span>
Line 469: Line 473:
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Open&nbsp;a&nbsp;TRANSMIT&nbsp;channel&nbsp;for&nbsp;output</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Öffnen eines TRANSMIT-Kanals für Ausgabe</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"comc.1:19200,8,n,1"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"comc.1:19200,8,n,1"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Output</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1</span>
Line 477: Line 481:
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Now&nbsp;open&nbsp;a&nbsp;RECEIVE&nbsp;channel&nbsp;for&nbsp;input</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Öffnen eines RECEIVE-Kanals für Input</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"comc.2:19200,8,n,1"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Open</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"comc.2:19200,8,n,1"</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">For</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">As</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Since&nbsp;there&nbsp;is&nbsp;no&nbsp;relation&nbsp;between&nbsp;the&nbsp;input&nbsp;and&nbsp;output&nbsp;pin</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Weil es keine Verbindung zwischen Input- und Output-Pin gibt</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'there&nbsp;is&nbsp;NO&nbsp;ECHO&nbsp;while&nbsp;keys&nbsp;are&nbsp;typed</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'gibt es KEIN ECHO wenn Tasten getippt werden</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Press&nbsp;any&nbsp;alpha&nbsp;numerical&nbsp;key"</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"Drücken Sie eine alphanumerische Taste"</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;</span>
 
<span style="font-family: 'Courier New';">&nbsp;</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'With&nbsp;INKEY()&nbsp;we&nbsp;can&nbsp;check&nbsp;if&nbsp;there&nbsp;is&nbsp;data&nbsp;available</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Mit INKEY() können wir prüfen, ob ein Zeichen verfügbar ist</span>
  
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'To&nbsp;use&nbsp;it&nbsp;with&nbsp;the&nbsp;software&nbsp;UART&nbsp;you&nbsp;must&nbsp;provide&nbsp;the&nbsp;channel</span>
+
<span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Bei der Benutzung mit der Software-UART muss der Kanal mit angegeben werden.</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Do</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Do</span>
  
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Store&nbsp;in&nbsp;byte</span>
+
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'In Byte speichern</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Inkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(#</span><span style="font-family: 'Courier New';">2</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span>
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Inkey</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(#</span><span style="font-family: 'Courier New';">2</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span>
  
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'When&nbsp;the&nbsp;value&nbsp;>&nbsp;0&nbsp;we&nbsp;got&nbsp;something</span>
+
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Wenn der Wert > 0 dann wurde etwas empfangen</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">></span><span style="font-family: 'Courier New';">&nbsp;0&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span>
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span><span style="font-family: 'Courier New';">&nbsp;B&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">></span><span style="font-family: 'Courier New';">&nbsp;0&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Then</span>
  
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">b</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Print&nbsp;the&nbsp;character</span>
+
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Print</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Chr</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">(</span><span style="font-family: 'Courier New';">b</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">)</span><span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Zeichen ausgeben</span>
  
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span>
 
<span style="font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">If</span>
Line 511: Line 515:
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span>
  
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Close&nbsp;the&nbsp;channels</span>
+
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Kanäle schließen</span>
  
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1</span>
 
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Close</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">#</span><span style="font-family: 'Courier New';">1</span>
Line 521: Line 525:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
After you have programmed the controller and you connected the serial cable, open the terminal emulator by clicking on&nbsp;[[File:Terminal-icon.png]]&nbsp;in Bascom.
+
Nachdem der Mikrocontroller programmiert und das Kabel angeschlossen wurde öffnen Sie das Terminal Emulator Fenster von BASCOM mit&nbsp;[[File:Terminal-icon.png]]&nbsp;.
  
You should see the program asking for an alphanumerical input, and it should print the input back to the terminal.
+
Sie sollten dann sehen, wie das Programm nach aplphanumerischer Eingabe fragt und dann sollte die Eingabe wieder im Terminal Fenster ausgegeben werden
  
  

Latest revision as of 01:49, 26 February 2013

Contents

UART

Ein Universal Asynchronous Receiver and Transmitter (UART) kann benutzt werden um Daten zwischen zwei Geräten zu senden und zu empfangen. Diese zwei Geräte können sein: PC-zu-PC, PC-zu-Mikrocontroller oder Mikrocontroller-zu-Mikrocontroller. Die UART Kommunikation benutzt TTL Spannungen von +5V and 0V oder LVTTL abhängig von der Mikrocontroller Betriebsspannung.

 

Wenn eine Verbindung zum PC gewünscht wird dann muss das RS232-Protokoll verwendet werden. Das bedeutet, dass mit definierten Spannungen (+15V und -15V) kommuniziert werden muss. Die kann mit einem MAX232 Level-Shifter erreicht werden.

 

Die Hardware wird im folgenden Schaltplan dargestellt:

 

Uart.png

 

Der DB-9 Anschluss hat 9 Pins aber es müsse nur 3 davon benutzt werden. Die obige Grafik zeigt die Vorderansicht - gelötet wird auf der anderen Seite. Bei den meisten Anschlüssen sind die Pinbezeichnungen auch auf den Steckern und Buchsen selbst zu lesen.

 

Wenn der verwendete Mikrocontroller HW-UART nicht unterstützt dann kann auch Software-UART benutzt werden. Siehe unten. Wenn der Mikrocontroller einen HW-UART unterstützt dann werden die TxD und RxD Pins mit TxD und RxD im Schaltplan verbunden. Wenn der Mikrocontroller mehrere HW-UARTs hat dann werden die TxD0 und RxD0 Pins mit TxD und RxD entsprechend obigem Schaltplan verbunden.

Nun muss per Programm der Mikrocontroller initialisiert werden. Öffnen Sie dazu eine neue .bas Datei und fügen Sie die folgenden Programmzeilen am Anfang hinzu.

 

$regfile = "verwendeter_mikrocontroller def.dat"

$crystal = 8000000

$baud = 19200

 

Stellen Sie sicher, dass der benutzte Mikrocontroller mit $regfile angegeben wird - zum Beispiel der ATMega32

$regfile = "m32def.dat"

 

Einige Mikrocontroller können einen internen Oszillator als Taktquelle verwenden. Einige Mikrocontroller verwenden den internen Oszillator standardmäßig. Bei Benutzung eines internen Oszillators braucht man keinen (externen) Quarz.

 

Führen Sie diesen Schritt nur aus wenn Sie einen internen Oszillator verwenden.

Öffnen Sie den BASCOM-AVR Programmer wie folgt:


Uart pg.png

 

Wählen Sie den “Lock and Fuse Bits” Tab aus und and maximimieren Sie das Programmer-Fenster.
Prüfen Sie, ob Sie den folgenden “Fusebit” Abschnitt sehen:

  "1:Divide Clock by 8 Disabled"

  und

        "Int. RC Osc. 8 MHz; Start-up time: X CK + X ms; [CKSEL=XXXX SUT=XX]"

 

Uart fusebits.png

 

Diese Einstellungen gibt es nicht bei jedem AVR Mikrocontroller. Wenn Sie die Einträge bei sich nicht haben dann ändern Sie nicht irgendwelche Fuse Bits.


 

Wenn diese Einstellungen verfügbar sind aber mit anderen Werten dann ändern Sie die Werte durch die Drop Down Möglichkeiten. Schließlich klicken Sie den "Program FS" Knopf und dann "Refresh" um die tatsächlichen Einstellungen zu sehen.

 

Verbinden Sie nun Mikrocontroller und PC mit einem Kabel mit DB-9 Anschluss

Schreiben Sie ein Testprogramm für Ihren Mikrocontroller welches folgendermaßen aussehen sollte:


 

$regfile = "m32def.dat" 'Verwendeter Mikrocontroller

$crystal = 8000000                                        

$baud = 19200                                            

 

Do

 Print "Hallo Welt"

Waitms 25

Loop

 

End

 

Öffnen Sie nun Das BASCOM Terminal-Programm und stellen Sie die Verbindungseinstellungen unter “Terminal” -> “Settings” ein. Wählen Sie den Com-Port wie am PC und stellen Sie eine Baudrate ein von 19200, Parity none, Data bits 8, Stop bits 1, Handshake none, emulation none.

 

Uart terminal.png Uart terminalshow.png

 

Wenn Sie das "Hallo Welt" im BASCOM Terminal Emulator Fenster angezeigt bekommen dann ist alles in Ordnung.

 

Beispiel

Sie können auch das folgende Programm mit dem BASCOM Terminal Emulator ausprobieren welches verschiedene Sende- und Empfangs-Befehle demonstriert.

 

$regfile = "m88def.dat"

$crystal = 8000000

$baud = 19200

 

Dim Akey As Byte  'Bytevariable deklarieren

 

Print

Print "Hallo, geben Sie irgendein alphanumerisches Zeichen ein.."

Akey = Waitkey()  'Waitkey wartet bis ein Zeichen von der UART empfangen wird

Print Akey

 

Wait 1

Print

Print "Danke! Wie Sie sehen gibt der Mikrocontroller eine Zahl aus."

Print "aber nicht das getippte Zeichen."

 

Wait 1

Print

Print "Probieren Sie nun die Enter-Taste.."

Akey = Waitkey()

Akey = Waitkey()

Print Akey

 

Print

Print "Die Zahl die Sie sehen ist der ASCII-Wert des eingetippten Zeichens."

Print "Wir müssen die Zahl wieder zurück umwandeln in das eingetippte Zeichen..."

Print     'Beachten Sie die Funktion dieser Zeile..

Print "Geben Sie wieder ein alphanumerisches Zeichen ein..."

Akey = Waitkey()

Print Chr(akey) 'Beachten Sie was hier passiert

Print "Jetzt klappt es!"

 

Wait 1

Print

Print "In vielen Situationen reicht ein Tastendruck nicht aus..."

Print "Geben Sie nun Ihren Namen ein und dann Enter zum Bestätigen"

 

Dim Inputstring As String * 12          'Zeichenkettenvariable deklarieren

 

 

Do

Akey = Waitkey()

If Akey = 13 Then Goto Thanks           'Bei Enter zu thanks springen

   Inputstring = Inputstring + Chr(akey) 'Zeichen an Zeichenkette anhängen/span>

Loop

 

Thanks:

Print "Vielen Dank" ; Inputstring ; " !"             'Beachten Sie die Funktion des Semikolons ; für mehrere Parameter

 

Wait 1

Print

Print "Sehen Sie sich den Programm-Code an und versuchen Sie zu verstehen,"

Print "wie das Programm arbeitet. Drücken Sie auch F1 während die Schreibmarke auf einem Befehl steht."

Print

Print "Wenn Sie alles verstanden haben dann gehen Sie weiter zum nächsten Beispielprogramm."

 

End

 

ASCII

Wie Sie im vorigen Beispiel gesehen haben benutzen wir den PRINT Befehl um irgendetwas zur UART zu senden. Genaugenommen senden wir nicht einfach Text sondern wir senden ASCII-Zeichen. ASCII heißt American Standard Code for Information Interchange. ASCII ist eine Tabelle mit 127 Zeichen.

 

ASCII Tabelle (unvollständig)

 

Dezimal  Hex    Binär     Wert

-------  ---    ------     -----

000    000   00000000      NUL    (Null char.)

008    008   00001000       BS    (Backspace)

009    009   00001001       HT    (Horizontal Tab)

010    00A   00001010       LF    (Line Feed)

012    00C   00001100       FF    (Form Feed)

013    00D   00001101       CR    (Carriage Return)

048    030   00110000        0

049    031   00110001        1

052    034   00110100        4

065    041   01000001        A

066    042   01000010        B

067    043   01000011        C

 

Die vollständige ASCII Tabelle finden Sie hier

 

CARRIAGE RETURN (CR) UND LINE FEED (LF)

Im vorigen Beispiel konnten Sie auch sehen, dass ein weiterer PRINT Befehl den Text in die nächste Zeile schreibt. Das kommt dadurch, dass der PRINT Befehl immer auch die CR und LF Zeichen anhängt uns ausgibt.

 

Wenn wir schreiben:

Print “ABC”

dann senden wir 65 66 67 13 10 to the UART. (Im Binär-Format)

 

Das Carriage Return Zeichen (13) bewegt die Schreibmarke zurück zur Position 0 der aktuellen Zeile. Das line feed (10) bewegt die Schreibmarke in die nächste Zeile.

 

Print “ABC” ;

Wenn wir ein Semikolon (;) am Ende der Zeile benutzen ...

sendet BASCOM kein carriage return/line feed so dass man weiteren Text nach dem ABC auf der selben Zeile schreiben kann.

 

Print “ABC” ; Chr(13) ;

Das würde nur ABC CR senden. Der nachfolgende Text würde das ABC überschreiben.

 

Übersicht

Hier finden Sie einige Befehle, die in Zusammenhang mit UART-Kommunikation benutzt werden können:

 

Waitkey()

Waitkey wartet bis ein Zeichen im seriellen Puffer empfangen wird.

 

Ischarwaiting()

Gibt eine 1 zurück wenn ein Zeichen im Hardware UART Puffer ansteht.

 

Inkey()

Inkey gibt den ASCII-Wert des ersten Zeichens aus dem seriellen Eingabe-Puffer zurück.

 

Print

Sendet eine variable oder eine konstante Zeichenkette zum UART.

 

 

 

Ein weiiteres Beispiel

Dieses Beispiel zeigt wie Ischarwaiting verwendet wird um zu prüfen ob eine Taste gedrückt wurde. Falls dies der Fall ist wird die Taste in eine Variable eingelesen:


 

'Print "Tippen Sie die Taste B um zu starten"

Dim Serialcharwaiting As Byte, Serialchar As Byte

 

Serialcharwaiting = Ischarwaiting()   'Prüfen, ob B oder b gedrückt wurde. Dann goto

If Serialcharwaiting = 1 Then

 Serialchar = Inkey()

If Serialchar = 66 Or Serialchar = 98 Then

    Goto MyRoutine

End If

End If

 

Goto Main

 

Myroutine:

'Anweisungen

 

Main:

'Anweisungen

End

 

 

BUFFERING SERIAL DATA

Wenn Sie mit hoher Geschwindigkeit senden und empfangen wollen dann müssen Sie serielle Input und serielle Output Puffer verwenden. Das Puffern wurde in BASCOM implementiert und kann nur mit Hardware UARTs verwendet werden.

 

Um einen UART für Pufferung zu konfigurieren muss der CONFIG Befehl benutzt werden.

 

Config Serialout Buffered Size 20

und/oder

Config Serialin Buffered Size 20

 

Mehr Informationen finden Sie in der BASCOM-Hilfe. Suchen Sie nach "config serialin". Es gibt auch ein Beispielprogramm “RS232BUFFER.BAS” im Samples-Verzeichnis.

 

 

SOFTWARE UART

Die bisherigen Beispiele benutzen die Hardware UART. Das bedeutet, dass die internen UART Register und interne Hardware (RxD(0) and TxD(0)) des AVR genutzt werden. Wenn Sie keinen Hardware UART haben dann können Sie auch Software UART benutzen.

 

Der BASCOM Compiler macht es leicht, weitere UARTS zu definieren. BASCOM kann fast jeden Pin für Software UARTs benutzen.


 

Bedenken Sie, dass Software UART nicht so stabil ist wie Hardware UART und deshalb kann man Timing-Probleme bekommen wenn viele Interrupts im Programm benutzt werden.

 

Für dieses Beispiel benutzen wir die Pins portc.1 und portc.2.

Verbinden Sie portc.1 mit TxD und portc.2 mit RxD entsprechend obigem Schaltplan.

 

Ändern Sie $regfile und programmieren Sie dieses Beispiel:

 

$regfile = "m88def.dat"

$crystal = 8000000

$baud = 19200

 

Dim B As Byte

Waitms 100

 

'Öffnen eines TRANSMIT-Kanals für Ausgabe

Open "comc.1:19200,8,n,1" For Output As #1

Print #, "serial output"

 

'Öffnen eines RECEIVE-Kanals für Input

Open "comc.2:19200,8,n,1" For Input As #2

'Weil es keine Verbindung zwischen Input- und Output-Pin gibt

'gibt es KEIN ECHO wenn Tasten getippt werden

 

Print #, "Drücken Sie eine alphanumerische Taste"

 

'Mit INKEY() können wir prüfen, ob ein Zeichen verfügbar ist

'Bei der Benutzung mit der Software-UART muss der Kanal mit angegeben werden.

Do

   'In Byte speichern

   B = Inkey(#2)

   'Wenn der Wert > 0 dann wurde etwas empfangen

   If B > 0 Then

      Print #, Chr(b)                         'Zeichen ausgeben

   End If

Loop

Close #2                                         'Kanäle schließen

Close #1

 

End

 

Nachdem der Mikrocontroller programmiert und das Kabel angeschlossen wurde öffnen Sie das Terminal Emulator Fenster von BASCOM mit Terminal-icon.png .

Sie sollten dann sehen, wie das Programm nach aplphanumerischer Eingabe fragt und dann sollte die Eingabe wieder im Terminal Fenster ausgegeben werden


Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language