Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Playing WAVs from a SD card with a dsPIC

Status
Not open for further replies.

Someone Electro

New Member
This is a little project i did in a few days. What is basically dose is it plays WAV files from a SD memory card. To interface the card i used microchips free file system lib.Here it is run on a dsPIC30F4013.

The audio output is done using PWM at over 100Khz. I didn't really expect much from it but the sound quality was amazingly good.It sounded as good as a real sound card. Because of that i didn't even think of using a real DAC.The player can play uncompressed WAV files with stanard sample rates from 8Khz to 48Khz. Since the output PWM could only do 8bit precision at such a high freq. the LSB of 16bit WAVs is ignored and stereo WAVs only play the left channel since i only used a single PWM channel. Also if the file is bouth 16 bit and stereo it canot play it at the higher sample rates because the bitrate becomes enormus and the pic cant read the card fast enugh anymore.(48Khz needs 1.5Mbit/s)

As i found it really difficult to find a proper SD card slot i quickly turned a peace of prefboard and a male header in to one and it makes a perfectly good contact with the card and allows the card to be simply pulled out.

The LEDs ware used for debugging, the pretty colorful flat cable is from the programmer and the big black one is the com port cable with a MAX232 in it. So where are the buttons and stuff? Well i was too lazy to give it some UI and just used the com port that was firstly used as debug and now to controll the player.

Oh and if you are wondering it is not possible to play a MP3 with a dsPIC because it is just not fast enugh to decode it in real time, so for that a MP3 decoder chip must be used. I have one of those around and will meaby try it out.
 

Attachments

  • 100_1369.jpg
    100_1369.jpg
    179.1 KB · Views: 890
  • sscom.png
    sscom.png
    24.3 KB · Views: 743
The audio output is done using PWM at over 100Khz. I didn't really expect much from it but the sound quality was amazingly good.It sounded as good as a real sound card. Because of that i didn't even think of using a real DAC.The player can play uncompressed WAV files with stanard sample rates from 8Khz to 48Khz. Since the output PWM could only do 8bit precision at such a high freq. the LSB of 16bit WAVs is ignored and stereo WAVs only play the left channel since i only used a single PWM channel. Also if the file is bouth 16 bit and stereo it canot play it at the higher sample rates because the bitrate becomes enormus and the pic cant read the card fast enugh anymore.(48Khz needs 1.5Mbit/s)

Nice one, but I would suggest you process the WAV on the PC to make it mono and only 8 bit, this will give you much longer playing times, and make your player routine simpler.

There's no problem with using the PWM module as a D2A, it is actually a 'real D2A', as much as any other.

Eight bits is fine for good sound quality, and is what the Commodore Amiga used (except that was stereo) way back before PC's ever thought of sound cards.
 
Yeah most files on that card are 8bit mono. Trying to play these files was a try to see when will the dsPIC finally give in. Because it was fast enough for anything i could throw at it.(Wanted to try 96Khz but sound recorder cant make those)

Oh and the card I'm using is 1GB (Smallest card i had uselessly laying around) Calculated it will store 12.5 h of 22KHz 8Bit WAVs

This library will also interface with a IDE hard drive with FAT32 (And no stupid 128GB limit like Win XP) But even a 1GB card is a huge overkill of memory for a little pic.
 
Yes. The interface is just simple SPI. I'm sure the 8051 does SPI, but if it doesn't then SPI is real easy to bit-bang too.
It can but it takes the only UART to do it. Our friend with the LPC ARM has it easier with 16 byte buffers on a SPI bus.
 
Ubergeek63:

Which chip exactly? I never seen any that cheap. Thats mainly why i chose PICs also because many are DIP and not only QFN/TQFP or w/e. In my own opinion its best for hobbyist.
 
Wow thats a nice chip. But to learn another heh either im lazy or i dont know but it would be a hassle to pickup a new thing for the sake of about $2-$4. I rather spend the extra since it technically comes with so much support :D (this forum and others)

But i never even heard of them? Or is it just me. I want to look into them some more. Thanks.
 
Wow thats a nice chip. But to learn another heh either im lazy or i dont know but it would be a hassle to pickup a new thing for the sake of about $2-$4. I rather spend the extra since it technically comes with so much support :D (this forum and others)

But i never even heard of them? Or is it just me. I want to look into them some more. Thanks.
You're welcome.

They were started a few years ago by ARM when the industry was deep into ARM7s and did not want to jump into the CORTEXs yet. The $50 '300 demo board is neat, I have one here. It has an OLED display and defaults to a nice little defender game :)

Dan
 
Cool! Which demo board? How about: EKK-LM3S1968 Evaluation Kit?

This really got my attention:
With entry-level pricing at $1.00 for an ARM technology-based MCU, Luminary Micro's Stellaris product line allows for standardization that eliminates future architectural upgrades or software tools changes.

Thats money i can throw away :D just kidding but at that kinda pricing i feel like it i dabble in it i wont really lose much if i dont like. But from what i read so far its really good and this :

Luminary Micro, Inc. designs, markets, and sells ARM® Cortex™-M3-based microcontrollers (MCUs). As ARM's lead partner for Cortex-M3 technology, Luminary Micro delivers the world's first silicon implementation of the Cortex-M3 processor, providing 32-bit performance at 8-/16-bit cost. Luminary Micro's award-winning Stellaris family of microcontrollers incorporates the Cortex-M3 MCU core running up to 50 MHz, embedded flash and SRAM, a 32-ch DMA, a low drop-out voltage regulator, battery backed low-power hibernation capability, integrated brown-out reset and power-on reset functions, analog comparators, 10-bit ADC, GPIOs, and watchdog and general purpose timers. The family also integrates several serial interfaces, including 10/100 Ethernet MAC+PHY, CAN, USB On-The-Go, USB Host/Device, SSI/SPI, UARTs, and I2C. Finally, the Stellaris family features peripherals designed specifically for intense industrial motor control, including motion control PWMs and quadrature encoder inputs.

Im too lazy to bold all the good stuff! lol but it looks like a good find.


EDiT:
Quiet a few instructions to learn tho. (alot lol)

Im going to buy this in 2 weeks:
Digi-Key - 726-1043-ND (Luminary Micro - EKI-LM3S811)
 
Last edited:
Cool! Which demo board? How about: EKK-LM3S1968 Evaluation Kit?
EKK-LM3S811 is the one I was thinking of, but I see the newer part has a kit with the GNU support configured: EKC-LM3S1968
Quiet a few instructions to learn tho. (alot lol)
It's not that bad actually. The biggest problem with ARMs was boot code and the interface between ARM and THUMB code. For most people it was handled by the compiler, but we were early on board. With CORTEX it all goes away since it is ALL thumb code.

Last I heard they were not even bothering to make assemblers available in general because the thing is so C friendly they are not needed, but that was early on.

Dan
 
Not sure if anyone notice the last but ill put it here:
Old edit
That sucz $200 for a compiler & IDE. WT* lol i guess i have to change my mind. Too much money to be lost. If this was a profession then maybe. But heh its a hobby for me. (as of now at least)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top