[Tested] Audio DAC’s – Alternative for the PT8211 – CS4334

madias
Tue Mar 27, 2018 7:58 pm
[Update:]
The CS434 is playing well with STM32F103, but ONLY with hardware I2S, because the DAC needs a master clock (MCLK) and only hardware I2s can provide it. For sure you can setup a timer faking/computing the master clock, but I doubt in an useful accuracy
So if you are on a board without I2s (C8,CB,RB…) consider using the PT8211 in I2s “fake” mode (SPI)

Many people here are experimenting with audio and I2S. I was the one who bring up the PT8211 into this forum as an extrem low cost (but not too bad sounding) Audio DAC.
While sorting out my “crafting things” (unmarked/-named vero boards with electronics) I found out, that I also experimented with the 24Bit CS4334 Audio DAC’s.
I mentioned that the output circuit is easier with single rail power supplies.
Look at the “typical connection diagram” on page 4:
http://www.mouser.com/ds/2/76/CS4334-5-8-9_F6-19636.pdf
Best of all: They totally drop in price for the last 2-3 years: 10 PCS for under 2.5 Euros on Aliexpress.
https://www.aliexpress.com/item/10PCS-C … 28100.html

Edit: Tested! The CS4334 works without problems – goto page 2 of this thread for code.


madias
Tue Mar 27, 2018 8:01 pm
Ups, I wrote about the CS4334 in 2015,
because used it with my PIC32’s:
(scroll a bit down):
viewtopic.php?t=57&start=20

…now I know why I have abandoned these DAC’s – but maybe it’s no problem with our new I2S-library, I have to check this out:
The cirrus devices are a little bit “special” because they need 4 lines (some I2s use only 3 lines, the cirrus devices needs the MCKL) Edit: They can also generate the master clock, but you have to sync it with the MCU:
MCLK 37 Master Clock (Input) – Clock source for the delta-sigma modulators.
SCLK 38 Serial Clock (Input/Output) – Serial clock for the serial audio interface.
SDIN 39 Serial Audio Data Input (Input) – Input for two’s complement serial audio data.
LRCK 40 Left Right Clock (Input/Output) – Determines which channel, Left or Right, is currently active on
the serial audio data line.


victor_pv
Tue Mar 27, 2018 9:46 pm
What about the TDA1387?

I saw it mentioned in several forums, seems like it’s pretty cheap too, $2 for 20pcs.
https://www.aliexpress.com/item/TDA1387 … 66193.html
likely fake

About MCLK, it’s available and the F1 I2S library should work, but I don’t have such a DAC to test it out.
The main differences with no using MCLK (from the library side) are that the MCLK needs to be configured for AFIO (should work fine), and the clock divider calculations are different (I hope it works, but haven’t tested). The clock calculations follow very closely the equivalent function in the STM HAL, and calculates the right settings when not using MCLK, so I believe they should work fine. At most, if someone tries and the clock is not rate, we may need to so some small change to the library.


madias
Tue Mar 27, 2018 9:47 pm
Note to myself – even with STM32F1xx generating master clock is possible:
http://www.st.com/content/ccc/resource/ … 190749.pdf
Chapter 1.6:
The I2S peripheral can be configured as the master or the slave in the audio communication.
The I2S generates its own clock (independent of the SPI clock used to interface registers to
the APB bus) using a 9-bit prescaler and designed to reach accurate audio frequencies
(8 kHz, 16 kHz, 22.05 kHz, 44.1 kHz, 48 kHz, etc.)(a). When configured in master mode, the
peripheral is able to output an additional master clock (MCLK) at a fixed rate: 256 × FS
(where FS is the audio frequency).

madias
Tue Mar 27, 2018 9:50 pm
[victor_pv – Tue Mar 27, 2018 9:46 pm] –
What about the TDA1387?

I saw it mentioned in several forums, seems like it’s pretty cheap too, $2 for 20pcs.
https://www.aliexpress.com/item/TDA1387 … 66193.html

Victor: I had very bad experience with TDA DAC’s (TDA1541) from Aliexpress because they are all fakes and work only with 8-bit (there are many people complaining about that) – so I would be careful with TDA chips (because they were never produced in china as I know)


victor_pv
Tue Mar 27, 2018 9:52 pm
Good to know! I’ll scratch off my post above to not mislead anyone.

madias
Tue Mar 27, 2018 9:55 pm
Main reason why I wrote about the CS4334 is that the chip is designed for single voltage supply, so we can use it without further audio circuits directly with the PAM(?) amplifier chip – only drawback is to setup a master clock (I don’t know if this feature is implemented in our I2S library – have to read tomorrow about it)
Edit: Ok, Victor edit the post above about I2s library and MCK ;)

victor_pv
Tue Mar 27, 2018 10:10 pm
The only drawback I see in using the MLCK signal, is that the new bluepill F4 board doesn’t have that pin in the headers, it’s instead one of the little solder test points in the underneath, PC7 for the first i2s port, and can’t remember for the second, but I think it was one of the PC pins test points too.

Would be nice to have a DAC we can use with the tiny blupillF4 board.


madias
Wed Mar 28, 2018 7:33 am
Dear Victor,
I’ve done a quick research about “Audio DAC – single voltage supply” – summery: The Cirrus Logic devices are still perfect, but they are all using MCLK.
Here is a comparison chart:
https://www.cirrus.com/solutions/#psearch
About your F4 mini board and PC7: Is there no way to afio_remap?

madias
Wed Mar 28, 2018 7:46 am
Ok, Victor I think I have an interesting candidate for you:
Cirrus Logic CS4350
https://www.cirrus.com/products/cs4350/

  • Automatic sample-rate detection
    Low-latency digital filtering
    Integrated PLL locks to incoming left-right clock – no MCLK required
    Supports PCM and TDM audio formats
    Single-ended or differential analog output architecture

On Ali i calculated for 10PCS about 6 Euros total (incl. shipping):
https://www.aliexpress.com/item/CS4350- … 37794.html


madias
Wed Mar 28, 2018 9:01 am
Victor: I examined your I2s library:
Is
disableDebugPorts();

madias
Wed Mar 28, 2018 1:27 pm
Here is a functionally I2s demo code for the CS4334
Setting up Master Clock was more than easy.
Output: Just sine left, saw right.
I used the I2S library (within sketch) from Victor (from the adafruit mp3 audio repro, think this is the latest version)
The magic line is
I2S.begin(I2S_PHILIPS_MODE, 48000, 16,1)

victor_pv
Wed Mar 28, 2018 2:02 pm
[madias – Wed Mar 28, 2018 9:01 am] –
Victor: I examined your I2s library:
Is
disableDebugPorts();

madias
Wed Mar 28, 2018 2:06 pm
Just for the record:
Ok, I didn’t managed to get 24 Bit output working. It maybe caused by “I2SClass::write(int32_t sample)” happend in 24 Bit mode – I don’t know.
…if anyone cares about 24 Bit (For “real 24 Bit” audio devices / applications we need much more than an STM32F103 ;) )

madias
Wed Mar 28, 2018 2:14 pm
Ok, Victor these were only two things I remembered…

Here is a photo of the really unspectacular circuit (only resistors and caps):


victor_pv
Wed Mar 28, 2018 5:38 pm
Did you use the 24bit mode? I am curious to know if it works.
The F1 i2s can’t send 24bits really, instead it sends 32bits, with 0’s padding either at the start or the end depending on some register settings. So would be good to know if the library works in that mode.

Just saw your post above the last one.
May have to do with the required rate in mclk in 24bit mode. I’ll have to read thru the datasheet for the CS and for the F1.


madias
Thu Mar 29, 2018 12:12 pm
Victor: It doesn’t bother, really :)
So, here is an example for I2s-DMA output:
// short DMA I2s CS4334 function test demo adapted by Matthias Diro using the I2s library from Victor Perez.
// sine output right, sqr output left
// sine array is size 512 and I2s-buffer is 512, so we can drive easily through the array

Leave a Reply

Your email address will not be published. Required fields are marked *