My first project using PIC micro-controllers. It's a little buggy and unfinished yet functional. The aim of this project is to record voice from an input line and save it in the SD card in a PCM uncompressed WAV file.
It's pretty simple: Just a PIC18F2525 or similar (we only need ADC and SPI module). I use a 7-segments LED display to debug (now it's useless).
It's simple but large because it requires FAT filesystem understanding and MMC access (which involves command/data sending and some requirements from the SD specs.).
The rest of the code it's self-explanatory and deals with sample acquisition and file writing (using 4 buffers because the write time depends on free cluster count and other things which aren't predictable).
sdcc is crap! It has some serious bugs with pointers, just have a look at fat.c and you'll see some strange code for doing simple things. It fails compiling some pieces of code with some assertion failure and I've seen other people code which say that it can generate bad code silently.
There's a strange (!!!) bug which I couldn't get rid of: using more than one FAT slows down the performance by 1/4 or more! Writing some data to the card took about 1 minute, with 2 FATs (the most common case) took 5 minutes. And it's stupid because the slowdown it's in the second FAT writing which takes more time than 10 or 20 512 bytes writing. If anyone solves it email me!