Compact FlashCard Driver

Top  Previous  Next

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 Flash Card 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 EEPROM for example.


For a file system at least the functions for reading (DriveReadSector / _DriveReadSector) and writing (DriveWriteSector / _DriveWriteSector) must be provided. The preceding under slash _ 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 File system, check the ASM-part of the functions-description.



Error Codes:



Compiler – Alias




No Error



This driver does not supports this function



No Drive is attached



During Reading or writing a time out occurred



Error during writing



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 :



A typical connection to the micro is shown below.