INPUT/de

From MCS Wiki AVR
< INPUT
Revision as of 01:24, 26 March 2013 by Stefanhamburg (Talk | contribs)
Jump to: navigation, search

Contents

Funktion

Ermöglicht Eingaben von der Tastatur, einer Datei oder über SPI.

 

 

Syntax

INPUT [" prompt" ] , var[ , varn ]

INPUT #ch, var[ , varn ]

 

 

Anmerkungen

Prompt

Optionale String-Konstante, die vor dem Prompt-Zeichen geschrieben wird.

Var,varn

Variable zur Aufnahme des Input-Wertes oder Strings.

Ch

Kanalnummer, die eine geöffnete Datei identifiziert. Kann eine Konstante oder eine Variable sein.

 

Die INPUT-Routine kann benutzt werden wenn man einen Mikrocontroller mit serieller Schnittstelle hat.

Die serielle Schnittstelle kann (über einen RS-232 - TTL Konverter) mit der seriellen Schnittstelle eines PCs verbunden werden.

Auf dieses Weise kann man die Tastatur des PCs mit einem Terminalemulator-Programm für Eingaben benutzen.

Man kann auch den in BASCOM integrierten Terminal-Emulator verwenden.

 

Bei Benutzung des AVR-DOS Datei-Systems kann man Variableninhalte aus einer geöffneten Datei lesen. Da die Variablenwerte im ASCII-Format gespeichert sind werden die Daten automatisch in das richtige Format umgewandelt.

Wenn INPUT in Zusammenhang mit Dateien benutzt wird dann ist PROMPT nicht unterstützt.


 

Unterschied zu VB

In VB kann man &H  mit INPUT spezifizieren und VB erkennt daraus, dass ein hexadezimaler Wert benutzt wird.

BASCOM hat den neuen Befehl INPUTHEX.

 

 

Xmega-SPI

When receiving data from the SPI interface, you need to activate the SS pin. Some chips might need an active low, others might need an active high. This will depends on the slave chip.

When you use the SS=AUTO option, the level of SS will be changed automatic. Thus SS is made low, then the data bytes are received, and finally , SS is made high again.

 

Receiving data works by sending a data byte and returning the data that is shifted out. The data that will be sent is a 0. You can alter this in the library, _inputspivar routine.

You can not sent constants using the INPUT with SPI. So INPUT #10, "SPI", var  is not supported.

INPUT used with SPI will not wait for a return either. It will wait for the number of bytes that fits into the variable. SeeCONFIG SPIx for an example.

 

Number of Bytes

The compiler will receive 1 byte for a variable which was dimensioned as a BYTE.

It will receive 2 bytes for a WORD/INTEGER, 4 bytes for a LONG/SINGLE and 8 bytes for a DOUBLE.

As with all routines in BASCOM, the least significant Byte will be received first.

 

If you specify an array, it will receive one element.

With an optional parameter you can provide how many bytes must be received. You must use a semicolon (;) to specify this parameter. This because the comma (,) is used to receive multiple variables.

 

Sample

Dim Tmparray(5) As Byte  , Spi_send_byte As Byte , W as Word

Input #12 , Spi_receive_byte ; 1                         ' READ 1 byte

Input #12 , Tmparray(1) ; 1 , Tmparray(2) ; B       ' read 1 byte and 'b' bytes starting at element 2

 

 

 

 

 

See also

INPUTHEX , PRINT , ECHO , WRITE , INPUTBIN

 

 

 

Example


'-----------------------------------------------------------------------------------------
'name : input.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: INPUT, INPUTHEX
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Dim V As Byte , B1 As Byte
Dim C As Integer , D As Byte
Dim S As String * 15
 
Input "Use this to ask a question " , V
Input B1 'leave out for no question
 
Input "Enter integer " , C
Print C
 
 
Inputhex "Enter hex number (4 bytes) " , C
Print C
Inputhex "Enter hex byte (2 bytes) " , D
Print D
 
Input "More variables " , C , D
Print C ; " " ; D
 
Input C Noecho 'supress echo
 
Input "Enter your name " , S
Print "Hello " ; S
 
Input S Noecho 'without echo
Print S
End

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