Audio DAC

I thought it would be nice to have some audio output a little more sophisticated than a simple 1-bit software-toggled speaker. An R/2R network would typically need 8 output bits for phone-quality audio, 16 or more for CD quality. PWM outputs use just one bit, but this has to be clocked at 256 or 65536 times the audio sampling rate for 8 or 16 bit resolution.

Fortunately, the huge consumer market for CD players means there are many CD-quality DACs on sale. They are all fed 16-bit data samples, but often filter and convert them at up to 24-bits per sample. Shopping around, I expected to see many cheap CD DACs for sale. Looking in the RS catalogue (and I appreciate this is not the best place to look for cheapness), DACs are surprisingly expensive. Granted, many are for non-CD applications, but you'd hoped to see just one cheap CD DAC in a few-pin package.

So I had a look through what was on offer and found the MAX549, with the following features:

GND 1 -MAX-
-
549-
8 VCC
OUTA 2 7 REF
!CS 3 6 OUTB
DIN 4 5 SCLK
Pin Names and functions
!CS Chip select
OUTA, OUTB Outputs, unbuffered (Zout ~ 33k3)
SCLK Serial clock, shifts data on rising edge
Vcc Power (2V5 to 5V5 DC)
GND Ground

Obviously 16 bits would be better, for CD-resolution, but this pushes the price up a lot and such chips tend to be surface mount. 8 bit resolution is good enough for TV sound.

The serial signals for CD DACs usually consist of serial data, serial clock, and a left/right clock. The latter selects which DAC channel receives the shifted data.

The MAX549 doesn't use this scheme though. Instead, it uses !CS to clock samples from the data shift register into the DACs. There are 16 data bits clocked in per conversion, the first 8 are control bits, the second 8 are the actual sample.

Dual-system interface

The two different schemes can be accommodated by assigning the following FPGA pins:

Left/Right Clock Used by CD DACs only
Serial Data Format depends on standard selected
Serial Clock Shifts data on rising edge
!CS Used by MAX549 only

The FPGA can contain logic to output in either format.

Sampling rates

There are various sampling rates used throughout the world. There is not much scope for common crystal clocking, though a few moments scribbling suggests an 18.432 MHz master clock would be useful:

Rate/Hz Chans Bits Application Using 18.432 MHz master clock
Divisor Freq./Hz Application Error/%
8000 1 8 Telephony 288 64000 8 x 8000Hz Telephony 0
8192 1 8 Telephony 280 65507.14... 8 x 8192Hz Telephony -0.044
44100 2 16 CD standard 26 708923 16 x (44307+11/16). 0.47
48000 2 16/24 Audiophile Music 24 768000 16 x 48 khz 0
96000 12 1536000 16 x 96 khz 0
192000 6 3072000 16 x 192 khz 0
          1843200 16 x 115200 (PC max baud rate) 0

However, I have got TV-colour carrier crystals in my system, so these give larger errors:

Application NTSC master clock
(315/22 =14,318,181.
81)
PAL master clock
17734475
Divisor Freq./Hz Error/% Divisor Freq./Hz Error/%
8 x 8000Hz Telephony 224 63920.45 -0.124 277 64023.37... 0.036
8 x 8192Hz Telephony 218 65679.7... +2.19 270 65683.24... 0.225
16 x 115200 (PC max serial port baud rate) 8 1789772.72 -2.9 10 1773447.5 -3.78
16 x (44100). CD standard 20 715909.09 +1.46 25 709379 +0.535
16 x 48 khz (Audiophile Music) 19 753588.5... -1.87 23 48191.50... +0.4
16 x 96 khz (Audiophile Music) 9 1590909.09 +3.57 12 92367.05... -3.78
16 x 192 khz (Audiophile Music) 5 2863636.36 -6.78 6 184734.11... -3.78

The figures above suggest that it might be best to:

The PC itself uses NTSC master clock for timing, so it may not be spot-on accurate for audio either.

Anyway, my main interest is getting an audio port to get simple sound effects to TVs or cheap speakers. Neither of these are hi-fi, and 8-bits will do. NICAM is a possibility, but requires extra analogue modulation and is not present in all TVs - especially not the cheaper ones.

Notes

This chip is refusing to work. I found the logic signals were a healthy 3V3, but the data sheet says VIH minimum is 70% of VDD. I.e 3V5 if VDD=5V, or worst case 3V85 if VDD=5V5. I changed the power rail to 3V3 but this hasn't helped. The setup and hold times are a few tens of ns, which a 1.77 MHz 6502 satisfies easily.

The LM386 amplifier seems to be working fine though. Worth noting that my mono speaker portable takes audio left and right, so the simple buzzer output can connect to one while the DAC connects to the other.