Select Page

Audio player using SD card

Problem Statement

To play raw audio files stored in SD card on WM8731 audio codec board using DMA.

Resources

TIVA Microcontroller (TM4C123G)

Micro SD card (2 GB) FAT 16 format

WM8731 audio codec board

Eclipse IDE

GCC

Project Overview

The aim of this project was to read raw audio files stored in the SD card (FAT 16 format) and play them on audio codec board using DMA.Multiple audio files cas also be stored and accessed from the SD card.

The pin connection for the Audio Codec board is as shown in the figure.

 

The pin connection for the codec board and the tiva board are shown below.

SD Card Driver

SD card driver consist of the following functions

1.disk_initialize()- This is for initialization of the SD card to work in SPI mode.

2.disk_read (drv,*buff,sector,count)- For reading a sector at the sector number given by sector from sd card.

Audio Codec Driver

Audio codec is interfaced via I2C communication protocol using following functions

1.I2CInit()- To initialize the I2C module.

2.WriteRegister(Register address, Data)- To write to control registers of the WM8731 codec.

There are total 11 registers (R0-R9 and RF) each containing 9 Bits of Data. This data controls power supply and filter on-off positions for input and output of Codec. They also store data for volume control such that left channel and right channel volume can be independently controlled. Also Codec has to be set in its Slave mode or Master mode which is configured by writing to these registers.

The register address uses only 7 bits to select the register, while as we already saw, each register holds 9 bit of data. As the I2C protocol will send 8 bits each time, we break this into 7+9=8+8. Thus while using write register, the first 8 bit address has [Address(6 downto 0)+Data(8)] , this is sent first to the slave module. When it is acknowledged, second 8 bit packet of [Data(7 downto 0)] is sent. Thus all 11 registers can be written by using the same method.

Implementation

1. Interface the SD card with the tiva microcontroller using SPI protocol via PORT A. The GPIO pins(Pin 2 to Pin5) of the PORT A are dedicated for serial communication using SSI. SSI module is configured to implement SPI with pins configured as Chip Select (PA3),MOSI(PA5),MISO(PA4) and Clock(PA2).

2. After interfacing the SD card data is read from it and stored in receive buffer in the memory.

3. Interface the audio codec board via I2C protocol using PORT B pins(3:2) and send the data stored in the receive buffer in the memory.

Future Work

1. Playing audio files from SD card through SPI interface using DMA channel of the tiva board and Audio Codec Board.

References

1. WM8731 Datasheet

2. SPI with SD Card – [1]

3. FAT 16 file system – [2]

4. Sample codes for peripherals provided along with tiva library.

5. TivaWare_Peripheral_Driver_Library__Users_Guide

6. TM4C123GH6PM_Microcontroller_Data_Sheet

Team Members

Yogesh Sehrawat

Sachin G