Wave file type player. The software has the functions needed to read SD/SDHC card formatted in FAT32. The software can play only PCM 22.050KHz, 8 bits, mono. The bytes from the file are streamed to CCP1 (PWM) modulated to the audio. The sound quality is OK for speech or medium quality music.
The software searches for files entries in the root directory only, it streams any file type without reading its name or type.
TO SET UP THE CARD:
Format the card with FAT32.
Create sound files type.wav
Name the files with short names, 8 low case characters max.
Save the files as 22.050KHz, 8 bits, mono.
Add the files to the root directory of the card (don't use a subdirectory).
The playback speed can be changed by changing the time of TMR0 in the code. The programming of the pic can be with 3.3V, if you have a pic programmer for 5V only remove the SD card while 5V is connected to the circuit, 5V will damage the SD card.
Hex file can be downloaded from my website: http://www.moty22.co.uk/sd.php
Troubleshooting: If the Error LED is on immediately on power up it means that the card failed to initialize. This code works for SD card rev 2 or SDHC card, it doesn't work for SDXC (1.8V) or MMC or SD rev 1 cards.For a successful recording a sector (512 Bytes) has to be writen in 20ms, some old SD cards may be too slow writing data to the flash memory, in such case the error LED comes on. Try another make of card.
More about FAT32 in this document: https://staff.washington.edu/dittrich/misc/fatgen103.pdf More about WAV in here: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ Good free specifications for SD can be found in SanDisk PDF: http://alumni.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf