Avr Dos
Avr Dos
ElectroRC
AVR-DOS BASCOM
AVR-DOS BASCOM
Bascom
AVR . Basic
.
AVR-DOS MMC .
SD
MMC FAT32, FAT16, FAT12
)
AVR-DOS FlashCardDrive CF (.
:
.
.
ATMEL Flash At45DBxxx
. -
SD MMC
.
:Memory cards
SD
SD MMC
SD
.
:
1 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
ElectroRC
AVR-DOS BASCOM
. SD mode
SPI mode
SPI
AVR 8mbps .
: . .
.
.
: DataIn MOSI CLK CSK DataOut MISO
.
2 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
ElectroRC
AVR-DOS BASCOM
BASCOM
BASCOM
" "Config_MMC.bas .
BASCOM . :
C:\Program Files\MCS Electronics\BASCOM-AVR\SAMPLES\AVRDOS
SPI .
Cmmc_soft
SPI .
/
.
:
#else
BASCOM FAT
BASCOM FAT
" "CONFIG_AVR-DOS.bas
-
:
C:\Program Files\MCS Electronics\BASCOM-AVR\SAMPLES\AVRDOS
FAT
.
.
cfilehandles
csepfathandle
.
:
SRAM .
) out of sram
.(space
3 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
ElectroRC
AVR-DOS BASCOM
FAT
. modify
RTC
.
"AVR-DOS File System
help BASCOM .
:
"$include "config_mmc.bas
"$include "CONFIG_AVR-DOS.bas
:
)(Drivecheck
:
A2:
If Drivecheck() <> 0 Then Goto A2
.
init:
)(Temp1 = Driveinit
.
.
FAT ... AVR-DOS
FAT .
.
)Temp1 = Initfilesystem(1
* .
.
:
4 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
BASCOM AVR-DOS
ElectroRC
function
chdir
Chdir \
Chdir .
mkdir
rmdir
Description
Change directoy
Go back to root directory
Come back to previous directory
Make new directory
Remove empty directory
sample
Chdir
Chdir
Chdir
Mkdir
Rmdir
ETC.
\
.
ETC.
ETC.
:
Mkdir ali.
Chdir ali.
- ali.
.
function
Description
sample
open
Open new file
*.refer to example
close
Close opened file
*.refer to example
flush
Save current file
*.refer to example
freefile
Return a free file number
*.refer to example
kill
Delete file
kill ETC.txt
filedate
Read date of generation file Temp=filedate(ETC.txt)
filetime
Read time of generation file Temp=filetime(ETC.txt)
filelen
Reverse length of file
Temp=filelen(ETC.txt)
dir
Show container of path
*.refer to example
. :
.
- freefile
:
Ff=freefile()
- FF
: open .
Open ETC.txt for binary as #ff
. binary ff
:
5 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
ElectroRC
AVR-DOS BASCOM
binary, input,
:
output, append
.
binary . append
. input
output .
:
)(Ff=freefile
Open ali.txt for input as #ff
:
read only -
.
:
)(Ff=freefile
Open ali.txt for binary as #ff
.
.
.
Flush #ff
6 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
BASCOM AVR-DOS
ElectroRC
Close #ff
flush
close )close
flush
.( config_avr-dos.bas
. :dir
:
Function search (byval name as string) as byte
Local st as string*12
St=
St=dir(*.*)
While len(st)>0
If st=name then
Search=1
Exit function
End if
St=dir()
Wend
Search=0
End function
function
Description
print
lineinput
get
put
seek
sample
7 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
BASCOM AVR-DOS
ElectroRC
:
Dim ff as byte
Dim le as long
Dim pos as word
Dim st as string*85
Ff=freefile()
Open ali.txt for binary as #ff
Print #ff,my name is ali taroosheh
Seek #ff,20000
Lineinput #ff,st
Close #ff
my name is ali taroosheh
.
. :eof
: UART
$baud=115200
Dim ff as byte
Dim count as long
Dim le as long
Dim acc as byte
Ff=freefile()
Open ali.txt for binary as #ff
Count=1
Do
Le=seek(#ff)
Get #ff,acc,le,count
Print chr(acc);
Loop until eof(#ff)<>0
Print EndOFFile
Close #ff
8 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
BASCOM AVR-DOS
ElectroRC
:get put
.
:
Dim ff as byte
Dim le as long
Dim count as word
Dim arr(512) as byte
Ff=Freefile()
Open ali.txt for binary as #ff
Le=1
Count=512
Put #ff,arr(1),le,count
Get #ff,arr(1),le,count
Close #ff
function
Description
sample
Drivecheck
9 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
BASCOM AVR-DOS
ElectroRC
Le=1000
Ptr=varptr(arr(1))
Err=drivereadsector(ptr,le)
Err=drivewritesector(ptr,le)
arr
.
10 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]
ElectroRC
AVR-DOS BASCOM
11 Weblog:www.ElectroRC.blogfa.com
Email:[email protected]