PWM driver audio DAC

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
zola1981
Posts: 3
Joined: Sun Dec 07, 2014 10:43 am

PWM driver audio DAC

Post by zola1981 »

Hi,
I really want to make an cheap MP3 player from an st32f401re (no lcd needed ).
Because the DAC cost almost the price of the nucleo board, I was thinking of the possibility to use the pwm and an LP Filter in order to get sound from it.
Elm Chan proved that with an attiny85 it could obtain an good quality wav player http://elm-chan.org/works/sd8p/report.html .
with an 84MHz (maybe with an little overclock) it could be possible to decode MP3 files and also output sound from the same chip?
For the moment I get the PWM working on an led !!!, but got some little questions...
pwm driver offer 3 mains characteristics:
-frequency -in my case want something like ~ 200kHz for the carryer
-period - witch will encode the actual audio data;
-fill factor - volume
the first problem where I'm stuck is how to change the period on the fly ?
Does anyone got an example generating sound using chibios on an stm32?

Regards,
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: PWM driver audio DAC

Post by Giovanni »

Hi,

I never tried this but you could use the PWM driver and change the duty cycle, it will behave exactly like a DAC. You will need an external low pass filter.

You could also change the duty cycle using a DMA channel, reading from memory and writing directly into the PWM timer comparator register. The DMA would be triggered by another timer (GPT driver).

Giovanni.
Post Reply