Saturday, May 22, 2010

PIC18F SD WAV Audio Player

As inspired by Simple SD Audio Player by ChaN, this project uses Microchip's PIC18F2550 to read RIFF WAVE files, and display some file information on the N6610 LCD; And then it will play the audio itself through PIC's PWM with a simple RC filter on the output pin. The hardware actually comes from my previous project, and I just attached a ready-made audio amp (w/ speaker) for the demo.
Due to PIC's peripheral limitations, I only set the PWM frequency to 187.5kHz and not the 250kHz carrier frequency originally used by ChaN, because it's the maximum PWM frequency than can still get an 8-bit resolution of the duty cycles (=48MHz/256). It is also possible to use R-2R ladder in stead of (low-pass) filtering the PWM output since there still enough unused digital output pins for this approach.
On the software part, I wasn't able to make a good data buffering as good as what ChaN did. It's noticeable with WAVE files with higher bit-rates (=SampleRate*NumChannels*BitsPerSample). Nevertheless, it can still support up to 48kHz sampling rate, but with only Mono channel and 8-bits/sample resolution.

demo video:

Source code(PICC-18) with and without LCD: PIC18 SD WAV Audio Player

My on-going project: currently porting the code to STM32F103RB for additional features.

Some useful software (shareware) tools:
TextAloud - Text to Speech software
Switch Sound File Converter-multi format audio file converters


  1. This comment has been removed by the author.

  2. This comment has been removed by the author.

  3. Please can you tell me how to compile this source (PIC18 SD WAV Audio) ? under PICC18 produces many errors.

  4. as reported (confirmed), errors will occur when using other versions of Hi-Tech PICC18 compiler. I've used the v9.64 of PICC18 to compile the above projects with no problems encountered.

  5. Dear Yus. I could not find online the version v9.64, but I have found two versions one v9.63 and v9.66 and both are not working to compile this code. Please help me. Is there a way to convert the code to C18?, or maIf you can attach file here is my hotmail accnt is gbrovage.

  6. hi i didnt work this device :S
    pls can u tell me how to compile this source? under PICC18 produces many errors.

  7. hi can u send me mmc file with sound for simulation in proteus. Thx

  8. Which kind of data i must set when i programer pic18f2550 in programator (osc,watchdog.....)
    When 1 burn this PIC he doesnt work.

  9. Could you maybe post a full circuit with all resistors caps crystals and the LED?

    1. I think that the led you see belongs to the amplifier. Not to the player.

  10. I think Text Speaker is one of the best text to speech software. You can use it for reading all your documents, emails, ebooks, and more. It also has a good selection of the most natural sounding voices in many different languages

  11. This comment has been removed by the author.

  12. I saw this clip and felt that it was easy, but for me it was not like it was in the clip. If anyone wants to know what it is, hurry to see this web site. สมัครบาคาร่า

  13. Well organized source of information. This can be used as reference for structuring the other sources of content. keep posting.
    Affiliate marketing guide

  14. Microsoft has launched the Xbox party chat application, which as the name implies will permit constant communication among gamers and will serve an extension of the Xbox Live. Xbox App's Party Chat

  15. relax gaming เว็บตรง สล็อตเว็บตรง ไม่ผ่านเอเย่นต์ สล็อตแตกง่าย ไม่มีขั้นต่ำ 2022

  16. หากจะเลือกเล่น เกมสล็อตสักเกม เราขอแนะนำเว็บ สล็อตเว็บตรงแตกง่าย ที่รวมเอาเกมสล็อตต่าง ๆ จาก ค่ายเกมสล็อตแตกง่าย แตกบ่อย