Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BASCOM AVR, help reference (2007).PDF
Скачиваний:
305
Добавлен:
12.08.2013
Размер:
17.02 Mб
Скачать

© MCS Electronics, 1995-2007

End

SPACE

Action

Returns a string that consists of spaces.

Syntax

var = SPACE(x)

Remarks

X

The number of spaces.

Var

The string that is assigned.

 

 

Using 0 for x will result in a string of 255 bytes because there is no check for a zero length assign.

See also

STRING , SPC

Example

'-----------------------------------------------------------------------------

 

--

: (c) 1995-2005, MCS Electronics

'copyright

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'purpose

: demonstrates DEG2RAD function

'-----------------------------------------------------------------------------

--

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 8000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 40

for the SW stack

' default use 40

$framesize = 40

for the frame space

 

Dim S As String * 15 , Z As String * 15

 

S = Space(5)

'{ }

Print " {" ; S ; " }"

Dim A As Byte

 

A = 3

 

S = Space(a)

 

page -666-

© MCS Electronics, 1995-2007

End

SPC

Action

Prints the number of specified spaces.

Syntax

PRINT SPC(x)

LCD SPC(x)

Remarks

X

The number of spaces to print.

 

 

Using 0 for x will result in a string of 255 bytes because there is no check for a zero length assign.

SPC can be used with LCD too.

The difference with the SPACE function is that SPACE returns a number of spaces while SPC() can only be used with printing. Using SPACE() with printing is also possible but it wil use a temporary buffer while SPC does not use a temporary buffer.

See also

SPACE

Example

'-----------------------------------------------------------------------------

 

--

: (c) 1995-2005, MCS Electronics

'copyright

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'purpose

: demonstrates DEG2RAD function

'-----------------------------------------------------------------------------

--

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 8000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 40

for the SW stack

' default use 40

$framesize = 40

for the frame space

 

Dim S As String * 15 , Z As String * 15

'{ }

Print "{" ; Spc(5) ; "}"

page -667-

© MCS Electronics, 1995-2007

Lcd "{" ; Spc(5) ; "}"

'{ }

SPIIN

Action

Reads a value from the SPI-bus.

Syntax

SPIIN var, bytes

Remarks

Var

The variable which receives the value read from the SPI-bus.

Bytes

The number of bytes to read. The maximum is 255.

 

 

See also

SPIOUT, SPIINIT, CONFIG SPI , SPIMOVE

Example

'-----------------------------------------------------------------------------

 

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

: spi.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo :SPI

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'-----------------------------------------------------------------------------

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

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 4000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

 

Dim B As Byte

 

Dim A(10) As Byte

 

Spiinit

 

B = 5

 

Spiout A(1) , B

 

Spiin A(1) , B

 

A(1) = Spimove(a(2))

 

End

 

page -668-

© MCS Electronics, 1995-2007

SPIINIT

Action

Initiate the SPI pins.

Syntax

SPIINIT

Remarks

After the configuration of the SPI pins, you must initialize the SPI pins to set them for the right data direction. When the pins are not used by other hardware/software, you only need to use SPIINIT once.

When other routines change the state of the SPI pins, use SPIINIT again before using SPIIN and SPIOUT.

See also

SPIIN , SPIOUT

ASM

Calls _init_spi

Example

See SPIIN

SPIMOVE

Action

Sends and receives a value or a variable to the SPI-bus.

Syntax

var = SPIMOVE( byte )

Remarks

Var

The variable that is assigned with the received byte(s) fromthe SPI-bus.

Byte

The variable or constant whose content must be send to the SPI-bus.

 

 

See also

SPIIN , SPIINIT , CONFIG SPI

Example

page -669-