Here you can find some sourcecode for the Microchip
PIC16F877 micro-controller.
I use it to write data to a CompactFlash-card in a (portable)
datalogger application. Because I want to read from the CF-card by
use of a pc (Linux, Windows) without the need for special tools,
I had to implement an accepted filesystem like FAT16.
The code supports RS-232 communication via the serial port,
115K2, 8N1, no flowcontrol. This communication is mainly used for
testing and debugging.
Because of the nature of the microcontroller and it's little memory-
size, this code has some major limitations:
- it doesn't support directories
- it doesn't support multiple files or partitions
- it doesn't support CF-cards with a size of more than 2GB
- it doesn't check for read- or write-errors
It does support just one file and it has the ability to format the
CF-card (which is strongly recommended before writing a new file).
The code is written in C and I use the BoostC compiler available at
http://www.sourceboost.com
which comes with a very easy to use IDE.
The circuit is based on a development kit from Arma Design
http://www.armanet.com/ and is
fairly simple.
Don't forget to implement a little circuit for RS-232 levelconverting
if you want to use the serial port, you can use a MAX233 ic for example.
For testing use a terminalprogram, select 115K2, 8N1, no flowcontrol
and local echo.
You can download the Compact-Flash specification at:
http://www.compactflash.org/
At some places this code could be improved somewhat, like changing
some multiplying algoritms by bitwise shift etc.
Maybe I will change that at a later time.
Submit errors or recommendations to teuniz@gmail.com
Disclaimer: use this code at your own risk, no warranty, blabla...
compactflash.c
cf_io.h
cf_io.c
rs232.h
rs232.c
schematic.pdf
devkitdocs.pdf