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

© MCS Electronics, 1995-2007

push r2

#endif

'*** here we call the routine ***

Stcheck

'*** when error <>0 then there is a problem ***

#if Testmode = 1 pop r2

pop r1 pop r0

#endif

Return

STOP

Action

Stop the specified device. Or stop the program

Syntax

STOP device

STOP

Remarks

Device TIMER0, TIMER1, COUNTER0 or COUNTER1, WATCHDOG, AC (Analog comparator power) or ADC(A/D converter power)

The single STOP statement will end your program by generating a never ending loop. When END is used it will have the same effect but in addition it will disable all interrupts.

The STOP statement with one of the above parameters will stop the specified device.

TIMER0 and COUNTER0 are the same device.

The AC and ADC parameters will switch power off the device to disable it and thus save power.

See also

START , END

Example

See START example

STR

Action

Returns a string representation of a number.

page -679-

© MCS Electronics, 1995-2007

Syntax

var = STR( x)

Remarks

var

A string variable.

X

A numeric variable.

 

 

The string must be big enough to store the result.

You do not need to convert a variable into a string before you print it.

When you use PRINT var, then you will get the same result as when you convert the numeric variable into a string, and print that string.

The PRINT routine will convert the numeric variable into a string before it gets printed to the serial port.

As the integer conversion routines can convert byte, integer, word and longs into a string it also means some code overhead when you do not use longs. You can include the alternative library named mcsbyte.lbx then. This library can only print bytes. There is also a library for printing integers and words only. This library is named mcsbyteint.

When you use these libs to print a long you will get an error message.

See also

VAL , HEX , HEXVAL , MCSBYTE , BIN

Difference with VB

In VB STR() returns a string with a leading space. BASCOM does not return a leading space.

Example

Dim A As Byte , S As String * 10 A = 123

S = Str(a)

Print S ' 123 'when you use print a, you will get the same result.

'but a string can also be manipulated with the string routines.

End

STRING

Action

Returns a string consisting of m repetitions of the character with ASCIICode n.

Syntax

var = STRING(m ,n)

Remarks

Var The string that is assigned.

page -680-

© MCS Electronics, 1995-2007

N

The ASCII-code that is assigned to the string.

M

The number of characters to assign.

Since a string is terminated by a 0 byte, you can't use 0 for n.

Using 0 for m will result in a string of 255 bytes, because there is no check on a length assign of 0.

See also

SPACE

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 = 40

for the SW stack

' default use 40

$framesize = 40

for the frame space

 

Dim S As String * 15

 

S = String(5 , 65)

'AAAAA

Print S

End

 

SUB

Action

Defines a Sub procedure.

Syntax

SUB Name[(var1 , … )]

Remarks

Name

Name of the sub procedure, can be any non-reserved word.

var1

The name of the parameter.

 

 

You must end each subroutine with the END SUB statement.

You can copy the DECLARE SUB line and remove the DECLARE statement. This ensures that you have the right parameters.

See Also

FUNCTION , CALL

See the DECLARE SUB topic for more details.

page -681-

© MCS Electronics, 1995-2007

SYSSEC

Action

Returns a Number, which represents the System Second

Syntax

Target = SYSSEC()

Target = SYSSEC(bSecMinHour)

Target = SYSSEC(strTime, strDate)

Target = SYSSEC(wSysDay)

Remarks

Target

A Variable (LONG), that is assigned with the System-Second

BSecMinHou A Byte, which holds the Sec-value followed by Min(Byte), Hour (Byte),

r

Day(Byte), Month(Byte) and Year(Byte)

StrTime

A time-string in the format „hh:mm:ss"

StrDate

A date-string in the format specified in the Config Date statement

wSysDay

A variable (Word) which holds the System Day (SysDay)

The Function can be used with 4 different kind of inputs:

1.Without any parameter. The internal Time and Date of SOFTCLOCK (_sec, _min, _hour, _day, _month, _year) is used.

2.With a user defined time and Date array. It must be arranged in same way (Second, Minute, Hour, Day, Month, Year) as the internal SOFTCLOCK time/date. The first Byte (Second) is the input by this kind of usage. So the SystemSecond can be calculated of every time/date.

3.With a time-String and a date-string. The time-string must be in the Format „hh:mm:ss". The date-string must be in the format specified in the Config Date statement

4.With a System Day Number (Word). The result ist the System Second of this day at 00:00:00.

The Return-Value is in the Range of 0 to 2147483647. 2000-01-01 at 00:00:00 starts with 0.

The Function is valid from 2000-01-01 to 2068-01-19 03:14:07. In the year 2068 a LONG – overflow will occur.

See also

Date and Time Routines , SYSSECELAPSED, SYSDAY

Example

Enable Interrupts

Config Clock = Soft

Config Date = YMD , Separator =.' ANSI-Format

Dim Strdate As String * 8

Dim Strtime As String * 8

page -682-