Jump to content

Controller to read wav files from SD CARD

Recommended Posts

It's interesting how the tda1541 only implemented the hi 10 bits as a resistor ladder but used charge balancing techniques for the least sig bits. Why would you not do that? It's bound to be more accurate than using discrete resistors. I think philips were trying to tell us something.


Never outside of automotive circles have i read so much unsubstantiated rubbish. Clearly the people that rabbit on about the type of capacitors have NFI.


I think it is time for you to start some experimentation as i'm answering your questions but you're not really grasping what i'm saying. It will become clear as you actually start to do something. What you're want to do is highly complex, so be prepared for a challenge.

Share this post

Link to post
Share on other sites

Thanks again for the replies.


I well know this is very complex, and I'm almost ready for the challenge.

I'm going to buy the STM32F4 Disco with base board and LCD expansions to start experimenting, but I'm confused about uC implementation, so I ask you more suggestions.


For the critical clock at 44.1 kHz (WS/LE) I'll derive it from master clock dividing by 256 with a pair of 74LVC161, because I believe they produce less jitter than the cpu.

Also for the bit clock, I can derive it from the divider (dividing by 8).

As for left open the two options, discrete DAC and TDA1541A in simultaneous mode, I have to manage two different format, signed integer 2's complements and offset binary, where allx'0' represents the maximum negative value instead of zero, but I think it's not difficult to do the conversion with the cpu.


So I could use the board's oscillator for the uC, since the critical timing are managed by the low jitter external master clock.

Now I have to understand how synchronize the data output from the cpu with the dividers.

First the uC must tell the counters to start when data are ready and to stop when whatever event happens.

Second I have to pull data from the uC output, one line or two depending on the format (simultaneous mode or not).

So, the cpu have to read data from SD card (SDIO) and outputs bits in a sort of buffer (SPI?) and manages the start/stop of the counter to feed the DAC.

Is that right? What port/bus can I use to do the job?




Share this post

Link to post
Share on other sites

The stm32f429 disco board already has the touch screen lcd. It has usb host, so you can use a usb memory stick instead of a sd card.


Why do you think lvc161 would have less jitter than the counters in the stm32f429? As i said before, the silicon in the stm32 is faster than the lvc161. Again, if the cpu is clocked from the magic oscillator, its timers can do the division for you synchronously.

You can also use the stm32 pwm outputs to vary the grid bias on the 12AX7.


You would most likely use the spi peripheral to output the bits.


Since your worried about jitter, how are you going to manage the layout of your circuit? Do you know what 1ps is in distance relative to the speed of light? Not much, i can tell you. So you will need to ensure the output latch clock signal to the 595s is equal in distance otherwise you'll get clock skews on the data output to the dac. Nina Hagen wont sound quite as good as we would like.

Share this post

Link to post
Share on other sites

The PCB layout is the last thing I'm thinking now, as you said there is much road to get this project working.

Usually I listen to a Steinway piano solo rather than Nina Hagen.


Ok, I start considering to get the right timing from the cpu, so I need to replace the original HSE clock of the Disco board with my oscillator. The original is 8MHz, mine is 11.2896MHz. I presume that I have to change something in some headers to tell the cpu is running at a different frequency. Am I wrong?


Using SPI to output bits, I can use SCLK as the bit clock for the DAC and MOSI to pump the bits in the DAC.

SCLK should come from a counter fed by the master clock.

But how can I clock the dac at 44.1 kHz to update? With GPIO?

Share this post

Link to post
Share on other sites

I was joking regarding Nina Hagen!


You will need to change the clock setup in the code. The actual cpu will run at a multiple of the crystal frequency. For the timers you would choose the crystal frequency as the source. You would setup one of the timers to divide your crystal frequency and output it on an associated pin. For the spi you can choose your clock source and prescaler to suit. If you set the timer for your 44.1kHz to interrupt, the code for this interrupt would load the spi with the data you want to send from a memory buffer. Alternately, it could trigger the dma to do it for you. In the background you read the data from the sdcard (or usb stick) and keep the buffer topped up. You should have enough time to update the user interface and respond to inputs.


Read the user manual for the stm32f4 - it's only a thousand pages or so........

Share this post

Link to post
Share on other sites

I was joking too, and I appreciate a lot your irony, "oxygen free copper wires facing towards Mecca" was fantastic!


Now is more clear, I'm looking to avoid reading a thousand pages.


As I understand I cannot use USB with my oscillator as the external clock, because USB interface requires multiple of 1 MHz clock, so I'll use the SD as the storage device.


Thinking to the TDA1541A firstly...

I have to replace the onboard 8 MHz HSE with mine 11.2896 MHz. I believe I have to desolder the 8 MHz crystal and a pair of capacitors, I'm not sure since I have no schematics of the Disco board

I need a couple of timers: the TDA1541A supports 6.4 MHz maximum bit clock, so the first timer should divide by 2 the master clock frequency. This clock should be stopped after the 16 bit for each channel in simultaneous mode (2 lines) are passed to the DAC.

The second timer should divide the master clock by 256 to get 44.1 kHz to update the DAC.

Can the cpu run at higher frequency using the PLL and the timers run at master clock frequency?

In other words, can the timers run in background starting from crystal frequency and output directly a GPIO, while the cpu works via the PLL?

With the TDA1541A, since it need two lines for data in simultaneous mode (left and right simultaneously), I believe I cannot use the SPI interface with a single data line.

Can I use other GPIO or what else?

Share this post

Link to post
Share on other sites

I would build a digital audio player with the following characteristics:

- it should read data from SD card only (up to 32GB size)

- SD card will be formatted FAT32

- the root of SD card will contain folders only (named as album title/artist)

- no subfolders will be allowed on SD card

- each SD card folder will contain wav files only (named as title track)

- only 16 bit / 44.1 kHz wav files will be allowed (CD quality)

- music data should be read and managed synchronously



these are my requirements...can anyone share examples related to it.



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...