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

© MCS Electronics, 1995-2007

IP2STR

Action

Convert an IP number into it’s string representation.

Syntax

Var = IP2STR(num)

Remarks

An IP number is represented with dots like 192.168.0.1. The IP2STR function converts an IP number into a string.

This function is intended to be used in combination with the BASCOM TCP/IP routines.

Var

The string variable that is assigned with the IP number

Num

A variable that contains the ip number is numeric format.

 

 

See also

CONFIG TCPIP

ISCHARWAITING

Action

Returns one(1) when a character is waiting in the hardware UART buffer.

Syntax

var = ISCHARWAITING()

var = ISCHARWAITING(#channel)

Remarks

Var

Byte, Integer, Word or Long variable.

 

Channel A constant number that identifies the opened channel.

If there is no character waiting, a zero will be returned.

If there is a character waiting, a one (1) will be returned.

The character is not retrieved or altered by the function.

While the Inkey() will get the character from the HW UART when there is a character in the buffer, it will return a zero when the character is zero. This makes it unusable to work with binary data that might contain the value 0.

With IsCharWaiting() you can first check for the presence of a character and when the function returns 1, you can retrieve the character with Inkey or Waitkey.

See also

page -541-

© MCS Electronics, 1995-2007

WAITKEY , INKEY

Example

$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 A As Byte , S As String * 2

 

Do

 

A = Ischarwaiting()

'we got something

If A = 1 Then

A = Waitkey()

'get it

Print "ASCII code " ; A ; " from serial"

 

End If

'until ESC is

Loop Until A = 27

pressed

 

KILL

Action

Delete a file from the Disk

Syntax

KILL sFileName

Remarks

sFileName A String variable or string expression, which denotes the file to delete

This function deletes a file from the disk. A file in use can't be deleted. WildCards in Filename are not supported. Check the DOS-Error in variable gDOSError.

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BSAVE , BLOAD , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT

ASM

Calls

_DeleteFile

 

Input

X: Pointer to string with

 

 

filename

 

Output

r25: Errorcode

C-Flag: Set on Error

page -542-

© MCS Electronics, 1995-2007

Partial Example

'We can use the KILL statement to delete a file. 'A file mask is not supported

Print "Kill (delete) file demo" Kill "test.txt"

LCASE

Action

Converts a string in to all lower case characters.

Syntax

Target = LCASE(source)

Remarks

Target

The string that is assigned with the lower case string of string target.

Source

The source string.

 

 

See also

UCASE

ASM

The following ASM routines are called from MCS.LIB : _LCASE

The generated ASM code : (can be different depending on the micro used ) ;##### Z = Lcase(s)

Ldi R30,$60

Ldi R31,$00 ; load constant in register Ldi R26,$6D

Rcall _Lcase

Example

$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 S As String * 12 , Z As String * 12

 

S = "Hello World"

 

Z = Lcase(s)

 

page -543-

© MCS Electronics, 1995-2007

Print Z

Z = Ucase(s)

Print Z

End

LCD

Action

Send constant or variable to LCD display.

Syntax

LCD x

Remarks

X Variable or constant to display.

More variables can be displayed separated by the; -sign

LCD a ; b1 ; "constant"

The LCD statement behaves just like the PRINT statement. So SPC() can be used too.

See also

$LCD , $LCDRS , CONFIG LCD , SPC , CLS

Example

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

 

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

: lcd.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR,

HOME

CURSOR, DISPLAY

'

'micro

: Mega8515

'suited for demo

: yes

'commercial addon needed

: no

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

 

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

 

$regfile = "m8515.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

 

page -544-

© MCS Electronics, 1995-2007

$sim

'REMOVE the above command for the real program !! '$sim is used for faster simulation

'note : tested in PIN mode with 4-bit

'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6

Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portc.7 , Rs = Portc.6

'These settings are for the STK200 in PIN mode

'Connect only DB4 to DB7 of the LCD to the LCD connector of the STK D4-D7 'Connect the E-line of the LCD to A15 (PORTC.7) and NOT to the E line of the LCD connector

'Connect the RS, V0, GND and =5V of the LCD to the STK LCD connector

Rem with the config lcdpin statement you can override the compiler settings

Dim A As Byte

Config Lcd = 16 * 2 'configure lcd screen

'other options are 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a 'When you dont include this option 16 * 2 is assumed

'16 * 1a is intended for 16 character displays with split addresses over 2 lines

'$LCD = address will turn LCD into 8-bit databus mode

 

'

use this with uP with external RAM and/or ROM

 

'

because it aint need the port pins !

 

Cls

 

'clear the LCD

display

 

'display this at

Lcd "Hello world."

the top line

 

Wait 1

 

'select the lower

Lowerline

line

 

 

Wait 1

 

'display this at

Lcd "Shift this."

the lower line

 

Wait 1

 

 

For A = 1 To 10

'shift the text to

Shiftlcd Right

the right

'wait a moment

Wait 1

Next

 

 

For A = 1 To 10

'shift the text to

Shiftlcd Left

the left

'wait a moment

Wait 1

Next

 

 

Locate 2 , 1

'set cursor

position

'display this

Lcd "*"

 

Wait 1

 

'wait a moment

Shiftcursor Right

'shift the cursor

Lcd "@"

 

'display this

Wait 1

 

'wait a moment

page -545-