Файл: Fast AVR. Basic compiller for AVR. User manual (2004).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 1441

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

FastAVR Basic compiler Manual

6.34.Display

Description:

Controls the LCD ON or OFF.

Syntax:

Display On|Off

Remarks:

Default is On.

Example:

Display

On

'Display

is

ON

Display

Off

'Display

is

OFF

Related topics:

LCD

Locate

Cls

Display

6.35.DegToRad

Description:

Converts Deegrees to Radians.

Syntax: var=DegToRad(var1)

Remarks:

var The var that is assigned Radians. var1 The Deegrees to convert.

Example:

Dim n As Byte

Dim f1 As Float, f2 As Float

f1=180

f2=DegToRad(f1) 'f2=3.141593

Related topics:

RadToDeg $Angles

100

FastAVR Basic compiler Manual

6.36.Do

Description:

Defines a loop of statements that are executed while a certain condition is thrue. Because test for condition is at the end of the loop, the loop itself will be executed at least once!

Syntax:

Do

statements

Exit Do

'you can EXIT from the loop at any time

Loop [While condition]

Remarks:

condition The Numeric or string expression that evaluates to True or False.

Statements within loop are executed at least one time, because test for condition is at the end of loop.

Useful for never ending loop.

Example:

Dim i As Byte

Do

' never ending loop

For i=0 To 5 Print Adc8(i) Waitms 250

Next Loop

Related topics:

6.37.DTMF

Description:

Generates DTMF tone.

Syntax:

DTMF(var)

Remarks:

var, expression or constant must be beetween 0 and 15

Key var and Tones Table

00

11

22

33

44

55

66

77

88

101


FastAVR Basic compiler Manual

99

10A

11B

12C

13D

14*

15#

ATTENTION!

Timer1 and OVF1 interrupt are used. User can NOT use this timer and interrupt for other purposes!

User MUST enable global interrupts

Enable Interrupts

and Ovf0 interrupt

Enable Ovf1

Note also that some filtering is necesary at the output (pin OC1)!

Example:

Enable Interrupts 'user must enable interrupts

DTMF(5)

Related topics: $DTMF

6.38.Enable

Description:

Enables Global Interrupts and/or individual Interrupts.

Syntax:

Enable Interrupts

Enable int

int is a valid Interrupt type

Remarks:

Check Interrupt types for each microcontroller used!

Example:

Enable

Interrupts

'enables

global

Interrupts

Enable

Ovf1

'enables

Timer1

Ovf1 Interrupt

Related topics:

Disable

Interrupts

102

FastAVR Basic compiler Manual

6.39.End

Description:

Ends program execution.

Syntax:

End

Remarks:

It is not necessary to use this statement if You are using a never-ending loop.

6.40.Exit

Sub

Function

For-Next

Do

While

6.41.Exp

Description:

Calculates a base number raised to a power.

Syntax:

var=Exp(numeric expression)

Remarks:

var receives a Exp of numeric expression numeric expression

Example:

Dim n As Float

n=Exp(3.45) 'n=3.150039E+01

Related topics:

Log

Log10

Pow

103


FastAVR Basic compiler Manual

6.42.Find8

Description:

Finds a value in a Table of bytes.

Syntax:

var=Find8(var1, TableName)

var returned value var1 search value

TableName Table which will be searched,

Remarks:

Function returns position of searched element or 0 if there is no such element!

Table must be declared as data in flash with number of elements and initialized (at the end of program).

Example:

Dim

n As Byte

Dim

Table(9) As Flash Byte

' number

of elements MUST be also declared

n=Find(55, Table)

' n will

be 5

Table = 11,22,33,44,55,66,77,88,99

'table of 9 elements

Related topics:

Find16

6.43.Find16

Description:

Finds a value in Table of Words or Integers.

Syntax:

var=Find16(var1, TableName)

var returned value var1 search value

TableName Table which will be searched

Remarks:

Function returns position of searched element or 0 if there is no such element!

Table must be declared as data in flash with number of elements and initialized (at the end of program).

Example:

Dim

n As

Word

Dim

Table1(9) As Flash Word

' number

of elements MUST be also declared

n=Find16(5555, Table1)

' n will

be 5

Table1 =

1111,2222,3333,4444,5555,6666,7777,8888,9999 'table of 9 elements

Related topics:

Find8

104


FastAVR Basic compiler Manual

6.44.For

Description:

Defines a loop of program statements whose execution is controlled by a loop counter.

Syntax:

For counter=start To stop [Step [-] StepValue] statements

[Exit For] 'you can EXIT from the loop at any time

Next

Remarks:

counter numeric variable - Byte, Integer or Word!

start numeric expression specifying initial value for counter stop numeric expression giving the last counter value

stepvalue numeric constant, default is 1, can be negative for decrement

Attention! Counter MUST be Byte, Integer or Word!

Example:

Dim i As Byte

Do

For i=0 To 5

Print Adc8(i)

WaitMs 250

Next

Loop

Related topics:

Do-Loop

While-Wend

6.45.Format

Description:

Defines Format for Print, Lcd, Tlcd, Glcd and Str().

Syntax:

Format(Int|Scientific,Frac)

Remarks:

Int Number of Integer numbers, - for Float max 10, min 1. Scientific (or 0) for scientific format, -x.xxxxxE+yy Frac Number of Fractal numbers, - for Float min 1.

Floating point numbers can be presented in normal: 6532.818

'Format(4,3)

or in Scientific Format: 6.532818E+03

'Format(Scientific,7)

Scientific format is Default for Float numbers!

Floating point numbers of Single precision has max 7 nums but can lay beetween 10E+38 and 10E-38. The last (7th) num is already rounded!

105

Print f
Print f
Print w
Print n

FastAVR Basic compiler Manual

Note that Format MUST be first mentioned under metastatement $LeadChar (for Byte, Integer, Word and Long - not for Float)!

Numbers are RIGHT justified!

Example:

Dim n As Byte, x As Word, f As Float

Dim s As String*5

n=65: w=1234: f=-1.234E+02

Format(3,0)

'output will be 065 (assume that "0" is defined as LeadChar) Format(4,1)

'output will be 0123.4 (assume that "0" is defined as LeadChar) Format(5,3)

'output will be -00123.400 (assume that "0" is defined as LeadChar) Format(Scientific,3)

'output will be -1.234E+02

Related topics: $LeadChar

6.46.Fract

Description:

Returns Fractional part of Float argument as Float.

Syntax:

var=Fract(numeric expression)

Remarks:

var receives a Fractional part of numeric expression numeric expression

Example:

Dim n As Float

n=Fract(3.45) 'n=0.45

Related topics:

Int

106