Oliver Rutsch

Playing .wav files from a SD card on a MC9S08QG8?

Discussion created by Oliver Rutsch on Aug 19, 2009
Latest reply on May 4, 2010 by Oliver Rutsch



I want to play some .wav sound files from a SD card on the QG8 MC. I already read a lot about 1-Bit PWM sound and on reading SD cards by SPI on AVR controllers. Fortunately SPI and the PWM module can use different pins on the QG8, so this should be possible. 

Every expired PWM period I'll get an interrupt and then I'll feed a new value for the duty cycle from a buffer.

So, what do you think, is the MCU fast enough (at 8MHz) to handle this?

I think I have to implement a small dobule-buffer sheme, which reads part of a sector in each buffer, because reading the flash directly in the ISR will be much too slow (some ms).

The main function will fill the buffers from the SD card and will poll a flag, which indicates the buffer switch (this happens when the ISR has finished playing one buffer).

What do you think about this concept? Any better ideas?


Thanks in advance and bye,