- •Table of Contents
- •Index
- •Keyword Reference
- •Installation
- •Installation of BASCOM
- •BASCOM IDE
- •Running BASCOM-AVR
- •File New
- •File Close
- •File Save
- •File Save As
- •File Print Preview
- •File Print
- •File Exit
- •View PinOut
- •View PDF viewer
- •View Error Panel
- •Edit Undo
- •Edit Redo
- •Edit Cut
- •Edit Copy
- •Edit Paste
- •Edit Find
- •Edit Find Next
- •Edit Replace
- •Edit Goto
- •Edit Toggle Bookmark
- •Edit Goto Bookmark
- •Edit Indent Block
- •Edit Unindent Block
- •Edit Remark Block
- •Program Compile
- •Program Syntax Check
- •Program Show Result
- •Program Simulate
- •Program Send to Chip
- •Tools Terminal Emulator
- •Tools LCD Designer
- •Tools LIB Manager
- •Tools Graphic Converter
- •Tools Stack Analyzer
- •Tools Plugin Manager
- •Tools Batch Compile
- •Options Compiler
- •Options Compiler Chip
- •Options Compiler Output
- •Options Compiler Communication
- •Options Compiler I2C, SPI, 1WIRE
- •Options Compiler LCD
- •Options Communication
- •Options Environment
- •Options Simulator
- •Options Programmer
- •Supported Programmers
- •ISP programmer
- •PG302 programmer
- •Sample Electronics cable programmer
- •KITSRUS Programmer
- •MCS Universal Interface Programmer
- •STK500 Programmer
- •Lawicel BootLoader
- •AVR ISP Programmer
- •USB-ISP Programmer
- •MCS Bootloader
- •Options Monitor
- •Options Printer
- •Window Cascade
- •Window Tile
- •Window Arrange Icons
- •Window Minimize All
- •Help About
- •Help Index
- •Help MCS Forum
- •Help MCS Shop
- •Help Support
- •Help Knowledge Base
- •Help Credits
- •BASCOM Editor Keys
- •Program Development Order
- •PlugIns
- •Font Editor
- •PinOut
- •BASCOM HARDWARE
- •Additional Hardware
- •AVR Internal Hardware
- •AVR Internal Registers
- •AVR Internal Hardware TIMER0
- •AVR Internal Hardware TIMER1
- •AVR Internal Hardware Watchdog timer
- •AVR Internal Hardware Port B
- •AVR Internal Hardware Port D
- •Adding XRAM
- •Attaching an LCD Display
- •Memory usage
- •Using the 1 WIRE protocol
- •Using the SPI protocol
- •Power Up
- •Chips
- •ATtiny22
- •ATtiny13
- •ATtiny15
- •ATtiny25
- •ATtiny45
- •ATtiny85
- •ATtiny26
- •ATtiny2313
- •ATMEGA8
- •ATMEGA16
- •ATMEGA32
- •ATMEGA48
- •ATMEGA88
- •ATMEGA168
- •ATMEGA64
- •ATMEGA103
- •ATMEGA128
- •ATMEGA161
- •ATMEGA162
- •ATMEGA163
- •ATMEGA165
- •ATMEGA169
- •ATMEGA323
- •ATMEGA603
- •ATMEGA8515
- •ATMEGA8535
- •BASCOM Language Fundamentals
- •Changes compared to BASCOM-8051
- •Language Fundamentals
- •Mixing ASM and BASIC
- •Assembler mnemonics
- •Reserved Words
- •Error Codes
- •Newbie problems
- •Tips and tricks
- •ASCII chart
- •BASCOM Language Reference
- •$BAUD
- •$BAUD1
- •$BOOT
- •$CRYSTAL
- •$DATA
- •$DEFAULT
- •$EEPLEAVE
- •$EEPROM
- •$EEPROMHEX
- •$EXTERNAL
- •$FRAMESIZE
- •$HWSTACK
- •$INCLUDE
- •$INITMICRO
- •$LCDPUTCTRL
- •$LCDPUTDATA
- •$LCDRS
- •$LCDVFO
- •$LOADER
- •$LOADERSIZE
- •$NOCOMP
- •$NOINIT
- •$NORAMCLEAR
- •$PROG
- •$PROGRAMMER
- •$REGFILE
- •$ROMSTART
- •$SERIALINPUT
- •$SERIALINPUT1
- •$SERIALINPUT2LCD
- •$SERIALOUTPUT
- •$SERIALOUTPUT1
- •$SWSTACK
- •$TIMEOUT
- •$TINY
- •$WAITSTATE
- •$XRAMSIZE
- •$XRAMSTART
- •1WIRECOUNT
- •1WRESET
- •1WREAD
- •1WSEARCHFIRST
- •1WSEARCHNEXT
- •1WVERIFY
- •1WWRITE
- •ACOS
- •ALIAS
- •ASIN
- •BASE64DEC
- •BASE64ENC
- •BAUD
- •BAUD1
- •BINVAL
- •BIN2GRAY
- •BITWAIT
- •BITS
- •BLOAD
- •BSAVE
- •BUFSPACE
- •BYVAL
- •CALL
- •CHECKSUM
- •CIRCLE
- •CLEAR
- •CLOCKDIVISION
- •CLOSE
- •CLOSESOCKET
- •CONFIG
- •CONFIG 1WIRE
- •CONFIG ACI
- •CONFIG ADC
- •CONFIG ATEMU
- •CONFIG BCCARD
- •CONFIG CLOCK
- •CONFIG CLOCKDIV
- •CONFIG COM1
- •CONFIG COM2
- •CONFIG COMx
- •CONFIG DATE
- •CONFIG DCF77
- •CONFIG DEBOUNCE
- •CONFIG I2CDELAY
- •CONFIG I2CSLAVE
- •CONFIG INPUT
- •CONFIG INTx
- •CONFIG GRAPHLCD
- •CONFIG KBD
- •CONFIG KEYBOARD
- •CONFIG LCD
- •CONFIG LCDBUS
- •CONFIG LCDMODE
- •CONFIG LCDPIN
- •CONFIG PORT
- •CONFIG PRINT
- •CONFIG PRINTBIN
- •CONFIG PS2EMU
- •CONFIG RC5
- •CONFIG SDA
- •CONFIG SCL
- •CONFIG SERIALIN
- •CONFIG SERIALIN1
- •CONFIG SERIALOUT
- •CONFIG SERIALOUT1
- •CONFIG SINGLE
- •CONFIG SPI
- •CONFIG SERVOS
- •CONFIG TCPIP
- •CONFIG TIMER0
- •CONFIG TIMER1
- •CONFIG TIMER2
- •CONFIG TWI
- •CONFIG TWISLAVE
- •CONFIG WAITSUART
- •CONFIG WATCHDOG
- •CONFIG X10
- •CONFIG XRAM
- •CONST
- •COSH
- •COUNTER0 and COUNTER1
- •CPEEK
- •CPEEKH
- •CRYSTAL
- •CURSOR
- •DATA
- •DAYOFWEEK
- •DAYOFYEAR
- •DATE$
- •DATE
- •DEBUG
- •DEBOUNCE
- •DECR
- •DECLARE FUNCTION
- •DECLARE SUB
- •DEFxxx
- •DEFLCDCHAR
- •DELAY
- •DISABLE
- •DISKFREE
- •DISKSIZE
- •DISPLAY
- •DO-LOOP
- •DriveCheck
- •DriveGetIdentity
- •DriveInit
- •DriveReset
- •DriveReadSector
- •DriveWriteSector
- •DTMFOUT
- •ECHO
- •ELSE
- •ENABLE
- •ENCODER
- •EXIT
- •FILEATTR
- •FILEDATE
- •FILEDATETIME
- •FILELEN
- •FILETIME
- •FLUSH
- •FORMAT
- •FOR-NEXT
- •FOURTHLINE
- •FRAC
- •FREEFILE
- •FUSING
- •GETADC
- •GETATKBD
- •GETATKBDRAW
- •GETDSTIP
- •GETDSTPORT
- •GETKBD
- •GETRC
- •GETRC5
- •GETTCPREGS
- •GETSOCKET
- •GLCDCMD
- •GLCDDATA
- •GOSUB
- •GOTO
- •GRAY2BIN
- •HEXVAL
- •HIGH
- •HIGHW
- •HOME
- •I2CINIT
- •I2CRECEIVE
- •I2CSEND
- •I2START,I2CSTOP, I2CRBYTE, I2CWBYTE
- •IDLE
- •IF-THEN-ELSE-END IF
- •INCR
- •INITFILESYSTEM
- •INITLCD
- •INKEY
- •INPUTBIN
- •INPUTHEX
- •INPUT
- •INSTR
- •ISCHARWAITING
- •KILL
- •LCASE
- •LCDAT
- •LCDCONTRAST
- •LEFT
- •LINE
- •LINE INPUT
- •LTRIM
- •LOAD
- •LOADADR
- •LOADLABEL
- •LOADWORDADR
- •LOCAL
- •LOCATE
- •LOOKDOWN
- •LOOKUP
- •LOOKUPSTR
- •LOWERLINE
- •MAKEBCD
- •MAKEINT
- •MAKEDEC
- •MAKETCP
- •MEMCOPY
- •NBITS
- •ON INTERRUPT
- •ON VALUE
- •OPEN
- •PEEK
- •POKE
- •POPALL
- •POWER
- •POWERDOWN
- •POWERSAVE
- •PRINTBIN
- •PSET
- •PS2MOUSEXY
- •PULSEIN
- •PULSEOUT
- •PUSHALL
- •RC5SEND
- •RC5SENDEXT
- •RC6SEND
- •READ
- •READEEPROM
- •READMAGCARD
- •RESET
- •RESTORE
- •RETURN
- •RIGHT
- •ROTATE
- •ROUND
- •RTRIM
- •SECELAPSED
- •SECOFDAY
- •SEEK
- •SELECT-CASE-END SELECT
- •SETFONT
- •SETTCP
- •SETTCPREGS
- •SENDSCAN
- •SENDSCANKBD
- •SERIN
- •SEROUT
- •SETIPPROTOCOL
- •SHIFT
- •SHIFTCURSOR
- •SHIFTIN
- •SHIFTOUT
- •SHIFTLCD
- •SHOWPIC
- •SHOWPICE
- •SINH
- •SOCKETCONNECT
- •SOCKETLISTEN
- •SOCKETSTAT
- •SONYSEND
- •SOUND
- •SPACE
- •SPIIN
- •SPIINIT
- •SPIMOVE
- •SPIOUT
- •SPLIT
- •START
- •STCHECK
- •STOP
- •STRING
- •SYSSEC
- •SYSSECELAPSED
- •SYSDAY
- •SWAP
- •TCPCHECKSUM
- •TCPREAD
- •TCPWRITE
- •TCPWRITESTR
- •TANH
- •THIRDLINE
- •TIME$
- •TIME
- •TOGGLE
- •TRIM
- •UCASE
- •UDPREAD
- •UDPWRITE
- •UDPWRITESTR
- •UPPERLINE
- •VARPTR
- •VERSION
- •WAIT
- •WAITKEY
- •WAITMS
- •WAITUS
- •WHILE-WEND
- •WRITE
- •WRITEEEPROM
- •X10DETECT
- •X10SEND
- •#IF ELSE ENDIF
- •International Resellers
- •International Resellers
- •ASM Libraries
- •EXTENDED I2C
- •MCSBYTE
- •MCSBYTEINT
- •TCPIP
- •LCD4BUSY
- •GLCD
- •GLCDSED
- •LCD-EPSON
- •AVR-DOS File System
- •CF Card
- •Compact FlashCard Driver
- •Elektor CF-Interface
- •XRAM CF-Interface for simulation
- •New CF-Card Drivers
- •Floating Point
- •FP_TRIG
- •DOUBLE
- •I2C SLAVE
- •I2CSLAVE
- •I2C TWI Slave
- •SPISLAVE
- •DATE TIME
- •EUROTIMEDATE
- •DATETIME
- •PS2-AT Mouse and Keyboard Emulation
- •AT_EMULATOR
- •PS2MOUSE_EMULATOR
- •BCCARD
- •BCCARD
- •BCDEF
- •BCCALL
- •BCRESET
- •Tools
- •LCD RGB-8 Converter
© MCS Electronics, 1995-2007
LCD-EPSON
This chip is compatible with PCF8533.
page -736-
© MCS Electronics, 1995-2007
AVR-DOS
AVR-DOS File System
The AVR-DOS file system is written by Josef Franz Vögel. He can be contacted via the BASCOM forum. Note that it is not permitted to use the AVR-DOS file system for commercial applications without the purchase of a license. A license comes with the ASM source.
You can buy a user license that is suited for most private users.
When you develop a commercial product with AVR-DOS you need the company license. The ASM source is shipped with both licenses.
Josef has put a lot of effort in writing and especially testing the routines.
Josef nor MCS Electronics can be held responsible for any damage or data loss of your CF-cards.
The File-System works with Compact – Flash Cards (see AN 123 Accessing a Compact Flash Card from BASCOM and Compact Flash ) and is written for the needs for embedded systems for logging data. There are further functions for binary read and write.
You do not need AN123. AN123 was used to develop AVR-DOS. So you should use AVR-DOS.
The intention in developing the DOS – filesystem was to keep close to the equivalent VB functions.
The Filesystem works with:
FAT16, this means you need to use >= 32MB CF cards
FAT32
Short file name (8.3)
(Files with a long file name can be accessed by their short file name alias)
Files in Root Directory. The root dir can store 512 files. Take in mind that when you use long file names, less filenames can be stored.
Files in SUBDIRS
Requirements:
Hardware: see AN 123 on http://www.mcselec.com/an_123.htm
Software: appr. 2K-Word Code-Space (4000 Bytes)
SRAM: 561 Bytes for Filesystem Info and DIR-Handle buffer
517 Bytes if FAT is handled in own buffer (for higher speed), otherwise it is handled with the DIR Buffer
534 Bytes for each Filehandle
This means that a Mega103 or Mega128 is the perfect chip. Other chips have too little internal memory. You could use XRAM memory too with a Mega8515 for example.
File System Configuration in CONFIG_AVR-DOS.BAS
cFileHandles: |
Count of Filehandles: for each file opened at same time, a filehandle |
|
buffer of 534 Bytes is needed |
cSepFATHandle: |
For higher speed in handling file operations the FAT info can be |
|
stored in a own buffer, which needs additional 517 Bytes. |
|
|
page -737-
© MCS Electronics, 1995-2007
Assign Constant cSepFATHandle with 1, if wanted, otherwise with 0.
Memory Usage of DOS – File System: 1. General File System information
Variable Name |
Type |
Usage |
gbDOSError |
Byte |
holds DOS Error of last file handling routine |
gbFileSystem |
Byte |
File System Code from Master Boot Record |
|
|
|
glFATFirstSector |
Long |
Number of first Sector of FAT Area on the Card |
gbNumberOfFATs |
Byte |
Count of FAT copies |
gwSectorsPerFat |
Word |
Count of Sectors per FAT |
glRootFirstSector |
Long |
Number of first Sector of Root Area on the Card |
gwRootEntries |
Word |
Count of Root Entries |
glDataFirstSector |
Long |
Number of first Sector of Data Area on the Card |
gbSectorsPerCluster |
Byte |
Count of Sectors per Cluster |
gwMaxClusterNumber |
Word |
Highest usable Cluster number |
gwLastSearchedCluster |
Word |
Last cluster number found as free |
|
|
|
gwFreeDirEntry |
Word |
Last directory entry number found as free |
glFS_Temp1 |
Long |
temorary Long variable for file system |
gsTempFileName |
String * |
temporary String for converting file names |
|
11 |
|
2. Directory
Variable Name |
Type |
Usage |
gwDirRootEntry |
Word |
number of last handled root entry |
glDirSectorNumber |
Long |
Number of current loaded Sector |
gbDirBufferStatus |
Byte |
Buffer Status |
gbDirBuffer |
Byte (512) |
Buffer for directory Sector |
|
|
|
3. FAT
Variable Name |
Type |
Usage |
glFATSectorNumber |
Long |
Number of current loaded FAT sector |
gbFATBufferStatus |
Byte |
Buffer status |
gbFATBuffer |
Byte(512) |
buffer for FAT sector |
|
|
|
4. File handling
Each file handle has a block of 534 Bytes in the variable abFileHandle which is a byte-array of size (534 * cFileHandles)
Variable Name |
Type |
Usage |
|
|
page -738- |
|
|
© MCS Electronics, 1995-2007 |
|||
|
|
|
|
|
|
FileNumber |
Byte |
File number for identification of the file in I/O |
|
||
|
|
|
operations to the opened file |
|
|
FileMode |
Byte |
File open mode |
|
||
FileRootEntry |
Word |
Number of root entry |
|
||
FileFirstCluster |
Word |
First cluster |
|
||
FATCluster |
Word |
cluster of current loaded sector |
|
||
FileSize |
Long |
file size in bytes |
|
||
FilePosition |
Long |
file pointer (next read/write) 0-based |
|
||
FileSectorNumber |
Long |
number of current loaded sector |
|
||
FileBufferStatus |
Byte |
buffer Status |
|
||
FileBuffer |
Byte(512) |
buffer for the file sector |
|
||
SectorTerminator |
Byte |
additional 00 Byte (string terminator) for direct |
|
||
|
|
|
reading ASCII files from the buffer |
|
|
Error Codes: |
|
|
|
|
|
|
|
|
|
|
|
Code |
Compiler – Alias |
|
|
Remark |
|
0 |
cpNoError |
|
|
No Error |
|
1 |
cpEndOfFile |
|
|
Attempt behind End of File |
|
17 |
cpNoMBR |
|
|
Sector 0 on Card is not a Master Boot |
|
|
|
|
|
Record |
|
18 |
cpNoPBR |
|
|
No Partition Sector |
|
19 |
cpFileSystemNotSupported |
|
Only FAT16 File system is supported |
|
|
20 |
cpSectorSizeNotSupported |
|
Only sector size of 512 Bytes is |
|
|
|
|
|
|
supported |
|
21 |
cpSectorsPerClusterNotSupported |
Only 1, 2, 4, 8, 16, 32, 64 Sectors per |
|
||
|
|
|
|
Cluster is supported. This are values of |
|
|
|
|
|
normal formatted partitions. Exotic sizes, |
|
|
|
|
|
which are not power of 2 are not |
|
|
|
|
|
supported |
|
33 |
cpNoNextCluster |
|
|
Error in file cluster chain |
|
34 |
cpNoFreeCluster |
|
|
No free cluster to allocate (Disk full) |
|
35 |
cpClusterError |
|
|
Error in file cluster chain |
|
49 |
cpNoFreeDirEntry |
|
|
Directory full |
|
50 |
cpFileExist |
|
|
|
|
65 |
cpNoFreeFileNumber |
|
No free file number available, only |
|
|
|
|
|
|
theoretical error, if 255 file handles in |
|
|
|
|
|
use |
|
66 |
cpFileNotFound |
|
|
File not found |
|
67 |
cpFileNumberNotFound |
|
No file handle with such file number |
|
|
68 |
cpFileOpenNoHandle |
|
All file handles occupied |
|
|
69 |
cpFileOpenHandleInUse |
|
File handle number in use, can't create a |
|
|
|
|
|
|
new file handle with same file number |
|
70 |
cpFileOpenShareConflict |
|
Tried to open a file in read and write |
|
|
|
|
|
|
modus in two file handles |
|
71 |
cpFileInUse |
|
|
Can't delete file, which is in use |
|
72 |
cpFileReadOnly |
|
|
Can't open a read only file for writing |
|
73 |
cpFileNoWildCardAllowed |
|
No wildcard allowed in this function |
|
|
97 |
cpFilePositionError |
|
|
|
page -739-
|
|
© MCS Electronics, 1995-2007 |
||
|
|
|
|
|
98 |
cpFileAccessError |
|
function not allowed in this file open |
|
|
|
|
mode |
|
99 |
cpInvalidFilePosition |
|
new file position pointe is invalid (minus |
|
|
|
|
or 0) |
|
100 |
cpFileSizeToGreat |
|
File size to great for function BLoad |
|
|
|
|
|
|
Buffer Status: Bit definitions of Buffer Status Byte (Directory, FAT and File)
|
Bit |
DIR |
FAT |
File |
Compiler Alias |
Remark |
|
0 (LSB) |
|
|
|
dBOF |
Bottom of File (not yet supported) |
|
1 |
|
|
|
dEOF |
End of File |
|
2 |
|
|
|
dEOFinSector |
End of File in this sector (last sector) |
|
3 |
|
|
|
dWritePending |
Something was written to sector, it must be |
|
|
|
|
|
|
saved to Card, before loading next sector |
|
4 |
|
|
|
dFATSector |
This is an FAT Sector, at writing to Card, |
|
|
|
|
|
|
Number of FAT copies must be checked and |
|
|
|
|
|
|
copy updated if necessary |
|
5 |
|
|
|
dFileEmpty |
File is empty, no sector (Cluster) is allocated |
|
|
|
|
|
|
in FAT to this file |
|
|
|
|
|
|
|
Validity of the file I/O operations regarding the opening modes
|
|
Open mode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Action |
|
Input |
|
Output |
|
Append |
|
Binary |
Attr |
|
|
|
|
|
|
|
|
Close |
|
|
|
|
|
|
|
|
Put |
|
|
|
|
|
|
|
|
Get |
|
|
|
|
|
|
|
|
LOF |
|
|
|
|
|
|
|
|
LOC |
|
|
|
|
|
|
|
|
EOF |
|
|
1) |
1) |
|
|
||
SEEK |
|
|
|
|
|
|
|
|
SEEK-Set |
|
|
|
|
|
|
|
|
Line Input |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Input |
|
|
|
|
|
|
|
|
Write |
|
|
|
|
|
|
|
|
1) Position pointer is always at End of File
Supported statements and functions:
INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BSAVE , BLOAD , KILL , DISKFREE , DISKSIZE , GET , PUT ,FILEDATE , FILETIME , FILEDATETIME , DIR , WRITE , INPUT , FILELEN
page -740-
© MCS Electronics, 1995-2007
page -741-