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

© MCS Electronics, 1995-2007

'this function can be used to display an IP number in normal format

Function Ipnum(ip As Long) As String

Local T As Byte , J As Byte

Ipnum = ""

For J = 1 To 4 T = Ip And 255

Ipnum = Ipnum + Str(t)

If J < 4 Then Ipnum = Ipnum + "."

Shift Ip , Right , 8

Next

End Function End

UPPERLINE

Action

Reset LCD cursor to the upperline.

Syntax

UPPERLINE

Remarks

Optional you can also use the LOCATE statement.

See also

LOWERLINE , THIRDLINE , FOURTHLINE , LCD, CLS , LOCATE

Example

Dim A As Byte

A = 255

Cls

Lcd A

Thirdline

Lcd A

Upperline

End

VAL

Action

Converts a string representation of a number into a number.

Syntax

var = VAL( s)

page -709-

 

© MCS Electronics, 1995-2007

Remarks

Var

A numeric variable that is assigned with the value of s.

 

S

Variable of the string type.

 

 

 

 

It depends on the variable type which conversion routine will be used. Single and Double conversion will take more code space.

When you use INPUT, internal the compiler also uses the VAL routines.

In order to safe code, there are different conversion routines. For example BINVAL and HEXVAL are separate routines.

While they could be added to the compiler, it would mean a certain overhead as they might never be needed.

With strings as input or the INPUT statement, the string is dynamic and so all conversion routines would be needed.

See also

STR , HEXVAL , HEX , BIN , BINVAL

Example

$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 = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

 

Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits

= 8 , Clockpol = 0

 

Dim A As Byte , S As String * 10

 

S = "123"

'convert string

A = Val(s)

Print A

' 123

S = "12345678"

 

Dim L As Long

 

L = Val(s)

 

Print L

 

End

 

VARPTR

Action

Retrieves the memory-address of a variable.

Syntax

var = VARPTR( var2 ) var = VARPTR( "var3" )

page -710-

 

© MCS Electronics, 1995-2007

Remarks

Var

The variable that receives the address of var2.

 

Var2

A variable to retrieve the address from.

 

var3

A constant

 

 

 

 

Sometimes you need to know the address of a variable, for example when you like to peek at it's memory content.

The VARPTR() function assigns this address.

See also

NONE

Example

Dim W As Byte

Print Hex(varptr(w)) ' 0060

VER

Action

Returns the AVR-DOS version

Syntax

result = VER()

Remarks

Result

A numeric variable that is assigned with the AVR-DOS version. The version

 

number is a byte and the first release is version 1.

 

 

When you have a problem, MCS can ask you for the AVR-DOS version number. The VER() function can be used to return the version number then.

See also

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

The VERSION() function is something different. It is intended to include compile time info into the program.

ASM

Calls

_AVRDOSVer

 

 

Input

-

Output

R16 loaded with value

 

 

page -711-

© MCS Electronics, 1995-2007

Example

Print Ver()

VERSION

Action

Returns a string with the date and time of compilation.

Syntax

Var = VERSION(frm)

Remarks

Var is a string variable that is assigned with a constant. This version constant is set at compilation time to MM-DD-YY hh:nn:ss

Where MM is the month, DD the day of the month, YY the year.

hh is the hour is 24-hour format, nn the minutes, and ss the seconds.

When frm is set to 1, the format date will be shown in eurpean DD-MM-YY hh:nn:ss format.

While it is simple to store the version of your program in the source code, it is harder to determine which version was used for a programmed chip.

The Version() function can print this information to the serial port, or to an LCDdisplay.

See Also

VER

Example

Print Version()

WAIT

Action

Suspends program execution for a given time.

Syntax

WAIT seconds

Remarks

seconds The number of seconds to wait.

page -712-