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

© MCS Electronics, 1995-2007

CF Card

Compact FlashCard Driver

The compact flash card driver library is written by Josef Franz Vögel. He can be contacted via the BASCOM user list.

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.

Compact flash cards are very small cards that are compatible with IDE drives. They work at 3.3V or 5V and have a huge storage capacity.

The FlashCard Driver provides the functions to access a Compact Flash Card.

At the moment there are six functions:

DriveCheck, DriveReset , DriveInit , DriveGetIdentity , DriveWriteSector , DriveReadSector

The Driver can be used to access the Card directly and to read and write each sector of the card or the driver can be used in combination with a file-system with basic drive access functions.

Because the file system is separated from the driver you can write your own driver.

This way you could use the file system with a serial eprom for example.

For a filesystem at least the functions for reading (DriveReadSector / _DriveReadSector) and writing (DriveWriteSector / _DriveWriteSector) must be provided. The preceeding underslash _ is the label of the according asm-routine. The other functions can, if possible implemented as a NOP – Function, which only returns a No-Error (0) or a Not Supported (224) Code, depending, what makes more sense.

For writing your own Driver to the AVR-DOS FileSystem, check the ASM-part of the functions-description.

Error Codes:

 

Code

Compiler – Alias

Remark

 

0

CpErrDriveNoError

No Error

 

224

cpErrDriveFunctionNotS

This driver does not supports this function

 

 

upported

 

 

225

cpErrDriveNotPresent

No Drive is attached

 

226

cpErrDriveTimeOut

During Reading or writing a time out occured

 

227

cpErrDriveWriteError

Error during writing

 

228

cpErrDriveReadError

Error during reading

At the MCS Web AN section you can find the application note 123.

More info about Compact Flash you can find at :

page -742-

© MCS Electronics, 1995-2007

http://www.sandisk.com/download/Product%20Manuals/cf_r7.pdf

A typical connection to the micro is shown below.

Elektor CF-Interface

The popular Electronics magazine Elektor, published an article about a CF-card nterfacei. This interface was connected to an 89S8252. This interface can be used and willuse little pins of the micro.

Note that because of the FAT buffer requirement, it is not possible to use a 8051 micro.,

At this moment, only the Mega128 and the Mega103 AVR micro’s are good chips to use with AVR-DOS.

You can use external memory with other chips like the Mega162.

page -743-

© MCS Electronics, 1995-2007

Changes of the hardware pins is possible in the file Config_FlashCardDrive_EL_PIN.bas.

The default library is FlashCardDrive.lib but this interface uses the library FlashCardDrive_EL_PIN.lib.

XRAM CF-Interface for simulation

The XRAM CF-Card interface is created for the purpose of testing the File System routines without hardware.

You can use an external RAM chip (XRAM) for the CF-interface but of course it is not practical in a real world application unless you backup the power with a battery.

For tests with the simulator it is ideal.

Just specify the Config_XRAMDrive.bas file and select a micro that can address external memory such as the M128. Then specify that the system is equipped with 64KB of external RAM.

You can now simulate the flashdisk.bas sample program !

In order to simulate Flashdisk.bas, set the constant XRAMDRIVE to 1. Then select 64KB of

page -744-

© MCS Electronics, 1995-2007

esternal RAM and compile.

New CF-Card Drivers

New CF-Card drivers can be made relatively simple. Have a look at the supplied drivers.

There are always a few files needed :

A config file in the format : CONFIG_XXX.bas

FlashCardDrive_XXX.LIB

FlashCardDrive_XXX.lbx is derived from the LIB file XXX stands for the name of your driver.

At the AVR-DOS web you can find more drivers.

page -745-