This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM to play wave file

Hello guys,
some one have experience to playing an wave file sampled at 44100Khz with 8 bit resolution mono by PWM micro device ?
I use STM Cortex 103 and I have also demo board that use this way to playng the file wave, but on board there is a SPI flash with file wave content. I in my real application don't have this memory and I can use only SDcard.
I have one timer interrupt that every 22 uS (time of sampled) operates taking one byte from buffer, so the buffer (large 2048 bytes) will reach the last byte after 45mS. In this time I must refill the old buffer and so way alternately.
Teorically it should work but I have big problem... some times the refill of buffer from SdCard is too slow.. fread from keil library lose 90mS... incredible !!
If I use only fread without starting the PWM, it works correctly.
Some suggestion ?

Thank a lot
Nicola

0