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

 

© MCS Electronics, 1995-2007

 

 

 

Mask

A file mask with a valid DOS filemask like *.TXT

 

 

Use *.* to select all files.

 

The first function call needs a file mask. All other calls do not need the file mask. In fact when you want to get the next filename from the directory, you must not provide a mask after the first call.

Dir() returns an empty string when there are no more files or when no file name is found that matches the mask.

See also

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

ASM

Calls

_Dir ; with filemask

_Dir0 ; without filemask

Input

X : points to the string with the

Z : points to the target variable

 

mask

 

Output

 

 

 

 

 

Partial Example

'Lets have a look at the file we created Print "Dir function demo"

S = Dir("*.*")

'The first call to the DIR() function must contain a file mask

'The * means everything.

WhileLen(s)> 0 ' if there was a file found

Print S ;" ";Filedate();" ";Filetime();" ";Filelen()

'print file , the date the fime was created/changed , the time and the size of the file S = Dir()' get next

Wend

DISABLE

Action

Disable specified interrupt.

Syntax

DISABLE interrupt

Remarks

Interrupt

Description

INT0

External Interrupt 0

page -459-

 

© MCS Electronics, 1995-2007

 

 

 

INT1

External Interrupt 1

 

OVF0,TIMER0, COUNTER0

TIMER0 overflow interrupt

 

OVF1,TIMER1,

TIMER1 overflow interrupt

 

COUNTER1

 

 

CAPTURE1, ICP1

INPUT CAPTURE TIMER1 interrupt

 

COMPARE1A,OC1A

TIMER1 OUTPUT COMPARE A interrupt

 

COMPARE1B,OC1B

TIMER1 OUTPUT COMPARE B interrupt

 

SPI

SPI interrupt

 

URXC

Serial RX complete interrupt

 

UDRE

Serial data register empty interrupt

 

UTXC

Serial TX complete interrupt

 

SERIAL

Disables URXC, UDRE and UTXC

 

ACI

Analog comparator interrupt

 

ADC

A/D converter interrupt

 

By default all interrupts are disabled.

To disable all interrupts specify INTERRUPTS.

To enable the enabling and disabling of individual interrupts use ENABLE INTERRUPTS.

The ENABLE INTERRUPTS serves as a master switch. It must be enabled/set in order for the individual interrupts to work.

The interrupts that are available will depend on the used microprocessor.

See also

ENABLE

Example

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

 

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

: serint.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: serial interrupt example for AVR

'micro

: 90S8535

'suited for demo

: yes

'commercial addon needed

: no

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

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

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

 

Const Cmaxchar = 20

'number of

characters

 

Dim B As Bit

'a flag for

 

page -460-

© MCS Electronics, 1995-2007

 

signalling a received character

'byte counter

Dim Bc As Byte

Dim Buf As String * Cmaxchar

'serial buffer

Dim D As Byte

 

'Buf = Space(20)

'unremark line above for the MID() function in the ISR

'we need to fill the buffer with spaces otherwise it will contain garbage

Print "Start"

 

On Urxc Rec_isr

'define serial

receive ISR

'enable receive

Enable Urxc

isr

 

Enable Interrupts

'enable interrupts

to occur

 

Do

'we received

If B = 1 Then

something

 

Disable Serial

'print buffer

Print Buf

Print Bc

'print character

counter

 

'now check for buffer full

'buffer full

If Bc = Cmaxchar Then

Buf = ""

'clear

Bc = 0

'rest character

counter

 

End If

 

Reset B

'reset receive

flag

 

Enable Serial

 

End If

 

Loop

 

Rec_isr:

 

Print "*"

'does it fit into

If Bc < Cmaxchar Then

the buffer?

'increase buffer

Incr Bc

counter

 

If Udr = 13 Then

'return?

Buf = Buf + Chr(0)

 

Bc = Cmaxchar

 

Else

'add to buffer

Buf = Buf + Chr(udr)

End If

 

' Mid(buf , Bc , 1) = Udr

'unremark line above and remark the line with Chr() to place

'the character into a certain position

'set flag

'B = 1

End If

'set flag

B = 1

page -461-

© MCS Electronics, 1995-2007

Return

DISKFREE

Action

Returns the free size of the Disk

Syntax

lFreeSize = DISKFREE()

Remarks

lFreeSize A Long Variable, which is assigned with the available Bytes on the Disk in Bytes

This functions returns the free size of the disk in Bytes.

See also

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

ASM

Calls

_GetDiskFreeSize

Input

none

Output

r16-r19: Long-Value of free Bytes

 

 

Partial Example

Dim Gbtemp1 As Byte ' scratch byte

Gbtemp1 =Initfilesystem(1) ' we must init the filesystem once

If Gbtemp1 > 0 Then

Print#1 ,"Error "; Gbtemp1

Else

Print#1 ," OK"

Print "Disksize : ";Disksize() ' show disk size in bytes

Print "Disk free: ";Diskfree() ' show free space too

End If

DISKSIZE

Action

Returns the size of the Disk

Syntax

page -462-