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

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

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

Добавлен: 12.06.2025

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

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

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

© MCS Electronics, 1995-2007

See also

DECR

Example

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

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

: incr.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: INCR

'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 A As Byte

A = 5

'assign value to a

Incr A

'inc (by one)

Print A

'print it

End

INITFILESYSTEM

Action

Initialize the file system

Syntax

bErrorCode = INITFILESYSTEM (bPartitionNumber)

Remarks

bErrorCode

(Byte) Error Result from Routine, Returns 0 if no Error

bPartitionNumber

(Byte) Partitionnumber on the Flashcard Drive (normally 1)

Reads the Master boot record and the partition boot record (Sector) fromthe flashcard and initializes the filesystem.

This function must be called before any other file-system function is used.

page -530-


© MCS Electronics, 1995-2007

See also

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

ASM

Calls

_GetFileSystem

Input

r24: partitionnumber (1-based)

Output

r25: Errorcode

C-Flag: Set on Error

Partial Example

Dim bErrorCode as Byte bErrorCode = InitFileSystem(1) If bErrorCode > 0 then

Print "Error: "; bErrorCode Else

Print "Filesystem successfully initialized" End If

INITLCD

Action

Initializes the LCD display.

Syntax

INITLCD

Remarks

The LCD display is initialized automatic at start up when LCD statements are used by your code.

If fore some reason you would like to initialize it again you can use the INITLCD statement.

The LCD routines depend on the fact that the WR pin of the LCD is connected to ground. But when you connect it to as port pin, you can use INITLCD after you have set the WR pin to logic 0.

ASM

The generated ASM code :

Rcall _Init_LCD

See also

LCD

page -531-


© MCS Electronics, 1995-2007

Example

NONE

INKEY

Action

Returns the ASCII value of the first character in the serial input buffer.

Syntax

var = INKEY()

var = INKEY(#channel)

Remarks

Var

Byte, Integer, Word, Long or String variable.

Channel

A constant number that identifies the opened channel if

software UART mode

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

Use the IsCharWaiting() function to check if there is a byte waiting.

The INKEY routine can be used when you have a RS-232 interface on your uP. The RS-232 interface can be connected to a comport of your computer.

As zero(0) will be returned when no character is waiting, the usage is limited when the value of 0 is used in the serial transmission. You can not make a difference between a byte with the value 0 and the case where no data is available.

In that case you can use IsCharwaiting to deterimine if there is a byte waiting.

See also

WAITKEY , ISCHARWAITING

Example

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

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

: inkey.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: INKEY , WAITKEY

'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

page -532-


© MCS Electronics, 1995-2007

$framesize = 40

' default use 40

for the frame space

Dim A As Byte , S As String * 2

Do

'get ascii value

A = Inkey()

from serial port

's = Inkey()

'we got something

If A > 0 Then

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

End If

'until ESC is

Loop Until A = 27

pressed

A = Waitkey()

'wait for a key

's = waitkey()

Print Chr(a)

'wait until ESC is pressed

Do

Loop Until Inkey() = 27

'When you need to receive binary data and the bibary value 0 , 'you can use the IScharwaiting() function.

'This will return 1 when there is a char waiting and 0 if there is no char waiting.

'You can get the char with inkey or waitkey then.

End

INP

Action

Returns a byte read from a hardware port or any internal or external memory location.

Syntax

var = INP(address)

Remarks

var

Numeric variable that receives the value.

address

The address where to read the value from. (0- &HFFFF)

The PEEK() function will read only the lowest 32 memory locations (registers).

The INP() function can read from any memory location since the AVR has a linear memory model.

When you want to read from XRAM memory you must enable external memory access in the Compiler Chip Options.

See also

OUT , PEEK , POKE

Example

page -533-