Interfacing a Texas Instruments PCM1725 Digital to Analog Converter (DAC) to a PIC16F690



I've recently become interested in adding sound to some microcontroller projects, and decided to use the PCM1725 manufactured by Texas Instruments. This chip is relatively cheap and comes in a SOIC package, which, while not as convenient as a DIP, is much easier to work with than an SSOP. This project is a minimalist approach and does not provide CD quality audio due to the low sampling rate, but I believe it is enough to show the concepts involved with making the PCM1725 work.

This project only includes three integrated circuits: a TI PCM1725 digital to analog converter that produces audio from binary data, an Atmel AT25DF041A memory chip to hold the binary sound file, and a Microchip PIC16F690 that controls the other chips. I used the internal clock on the 16F690 running at 8Mhz with clockout on the RA4 pin, which provides the system clock for the PCM1725 at 2Mhz. Thus, the sampling rate is limited to around 7,800 samples/sec. since the system clock must be 256 or 384 times the sampling frequency. The PCM1725 requires the following inputs: system clock at 256 or 384 times the sampling frequency, Left/Right clock that clocks in the data for the left and right channels at one cycle per sample (1/256th or 1/384th the system clock frequency), bit clock that clocks in the binary data one bit at a time (though the datasheet is silent on the frequency, it should be 64 cycles per sample, or 32 bits per channel per sample), and the binary audio data. Each of these except for the binary audio data is provided by the 16F690. The binary information is delivered from the memory chip directly.

The pins of the chips are mapped as follows:

Pic RC7 - Memory Chip SI
Pic RB6 - Memory Chip SCK and PCM1725 BCKIN
Pic RC4 - Memory Chip Chip Select
Pic RB7 - PCM1725 LRCIN
Pic RA4 - PCM1725 SCKI
Memory chip SI - PCM1725 DIN

Following is a very nonprofessional schematic of the way I wired it up.

PCM1725 Circuit


Note that I tied the format pin to ground in order to use standard data entry formatting instead.

So here is how it works. The PIC16F690 initiates a read command on the memory chip, which already has the audio data loaded. For the AT25DF041A, this is done by clocking in the 1 byte Read command ("3" in binary) followed by the three address bytes, which are all 0's for my application since I want to start with the first byte. Following the read command, the memory chip places the first bit of information on the SO pin (all information is clocked out on the down cycle of the data clock). The RB7 pin on the PIC16F690 is pulled high to begin clocking in the left channel data (LRCIN pin on the PCM1725). All subsequent cycles of the RB6 pin on the 16F690 clock in data into the PCM1725 on the upswing and retrieve the next bit from the memory chip on the downswing. Following 32 cycles of RB6, RB7 is pulled down to clock in the left channel byte information that was just entered and start entering the right channel information in the same manner. After 32 bits have been entered, the RB7 pin (LRCIN on the PCM1725) is pulled high to clock in the right channel information and start entering the next sample.

Click here for the firmware, written in Hi-Tech C for the PIC 16F690

One note on the formatting of the audio file on the memory chip. The data must be entered MSB fist (Big Endian), which means that the bytes must be reversed if you are using a .wav file, since they are entered in Little Endian form. See this page for more information on the .wav (WAVE) file format. Also, since the PCM1725 is only 16 bit, you must make sure that the 16 bits of data are the last 16 bits clocked in prior to changing the state of the LRCIN pin if you are using the Standard data entry format. I think you can accomplish this by using the HOLD feature on the memory chip, but I handled it by adding two 0's to each sample so that the originally 16-bit data becomes 32 bit data (i.e., 232 17 becomes 0 0 232 17). This ensures that the 16 bits of audio data are clocked in during the last 16 cycles of BCKIN, as specified in the PCM1725 datasheet. Also, note that if you start with a .wav file that has only one channel (mono vs. stereo), you need to load each sample twice onto the memory chip - one each for the left and right channel.

Again, this is a very basic application and not great audio since this sampling frequency is below the minimum specified in the PCM1725 datasheet. However, this should at least get you started. I believe you could use a binary counter attached directly to the clock source to handle the bit clock and LRCIN functions (RB6 and RB7 on the PIC 16F690). Though this was written specifically for the PCM1725, I think the same principles can be used for the ther Texas Instrumet DAC chips, including PCM1795, PCM1789, PCM1774, PCM1780, PCM1781, PCM1782, PCM1798, PCM1796, PCM1773, PCM1772, PCM1771, PCM1770, PCM1748, PCM1742, PCM1741, PCM1740, PCM1744, PCM1727, PCM1794, PCM1793, PCM1792, PCM1791, PCM1755, PCM1754, and PCM1753.


Make sure you check out my projects:

USB Serial Communication using the Microchip MCP2200 - Interfacing microcontrollers with a computer using this cheap chip.

Interfacing a PCM1725 to a PIC16F690 - Adding audio to a project by interfacing a PCM1725 DAC to a PIC16F690.

Using the Avago ADNS-2610 Sensor - Programming an optical sensor from an optical mouse.

USB Communications using the PIC18F4550 - Programming a microcontroller to communicate with a computer via the USB port

Interfacing to Microcontrollers to SD Cards - Accessing files stored on SD Cards in FAT16 format via the SPI module in a microcontroller

Building Electronic Drums - How to construct electronic drums using piezo sensors

Circuit Archive - If you are looking for other sample circuits for various uses and components, this is the place for you.

Component List - If you are looking for suppliers for different project components, I've compiled some good ones here.

Any questions or comments - contact me at pwclark1977@hotmail.com