This chapter deals with two types of serial communication Inter-Integrated Circuit (I2C) and Serial Peripheral Interface (SPI). Already, one serial communication protocol UART is discussed earlier in Chap. 12. These two peripherals give access to control various features. The features that are covered in this chapter are Real Time Clock (RTC) which can be used for time stamping applications, digital-to-analog converter (DAC) to generate analog signal, microSD card for mass data storage, TV interfacing using composite channel for display. Lots of interesting projects can be developed by combination of these peripherals. As for transceivers like RS232, MAX485 transmission and receiving range is around 2–120 m depending on baud rate and type of transceiver used. But I2C and SPI serial communication cannot be used for such distant communication, generally used to interface devices on same PCB.

1 Inter-Integrated Circuit (I2C)

1.1 Introduction

Inter-Integrated Circuit (I2C) also known as two wire interface. As this serial communication requires two lines, data line (SDA) and clock (SCL). On PadmaBoard, real time clock (RTC) and two 12-bit DAC to generate analog signals are present. Both of these features are based on I2C protocol. There is I2C bus connector on the PadmaBoardFootnote 1 to which other breakout boards having different features based on I2C can be connected. Microcontroller on Tiva LaunchPad, TM4C123GH6PM has four such I2C modules with various features as mentioned below:

  • Devices on I2C bus can be configured as master or slave.

  • Supports four modes: Master Transmit, Master Receive, Slave Transmit and Slave Receive.

  • Supports four transmission speeds: 100 Kbps, 400 Kbps, 1 Mbps, and 3.33 Mbps.

  • Various end or begin of transmission based interrupts in both master and slave mode.

  • Supports multiple masters and 7-bit addressing mode.

To operate the I2C at Fast Mode (i.e., 400 Kbps), or Fast Mode Plus (i.e., 1 Mbps) or at High-Speed Mode (i.e., 3.33 Mbps), there is minimum amount of system clock requirement by microcontroller for each mode. For more details on minimum system clock requirement refer to microcontroller datasheet.

1.2 Functional Description

I2C has two open-drain lines, data line (SDA), and clock (SCL). These lines are pulled up to VCC via pull up resistors. Advantage of I2C is that multiple number of devices with different address can be connected on the same I2C bus. Among the devices there will masters and slaves.Footnote 2 And depending on request, data transfer will take place either from master to slave or from slave to master. Hence, SDA line will be bi-directional. So, this protocol empowers the user to control various devices (with different address) by using only two lines (SDA and SCL).

Similar, to UART serial communication, I2C has start and stop bits. To generate start bit SDA need to be pulled low by keeping SCL high and to generate the stop bit SDA will be pulled high by keeping SCL high. And all the other bits related to data, address of slave, acknowledgment of data, and direction of flow of data (master to slave or slave to master) will be signaled between the start and stop bits. There are two frames, address frame, and data frame. These frames will be signaled between the start and stop bits.

  1. 1.

    Address Frame - This frame needs to be sent first to initiate transactions on I2C bus. This frame comprises of 9-bits. Among them first 7-bits are for the slave address. The 8th bit of the frame will be indicated by the direction of flow of data (data will be transmitted from master to slave or data will be transmitted from slave to master). These 8-bits are driven by the master, after that master releases the SDA line. And the last bit, 9th bit will be acknowledgment bit driven by the slave. If slave of corresponding address which is transacted in beginning of the frame is present then that slave will pull the acknowledgment bit low else if it is not present the bit will remain high.

  2. 2.

    Data Frame - This frame is transacted after the address frame. The first 8-bits of this frame are data bits which will transmitted from master to slave or slave to master depending on the direction bit in address frame. The last bit, 9th bit will be acknowledgment bit transmitted by receiving end (it can be master or slave).

If there is an application in which master is performing a transaction of bulk of data with the same slave in same direction (i.e., either transmitting or receiving) then there is no need to send the address frame before each data byte. Only, before the first data byte address is signaled then series of data frames are signaled, this is the burst transaction mode. However, if there is need to switch to some other slave or to change the direction of flow of data then the address frame will be signaled before the next data frame. This is illustrated in Fig. 1.

Fig. 1
figure 1

Transaction modes of I2C

If there are multiple masters or slaves on I2C bus, then slaves can not communicate with each other. Similarly, masters cannot communicate among themselves. Only master and slave communication is possible. If two masters want to communicate with each other then one has to become a slave, similarly for communication between slaves. Figure 2 shows the block diagram containing one I2C master and multiple slaves.

Fig. 2
figure 2

Block diagram for I2C connection

In case of multiple masters, only one master will be holding the bus at a given time. Only the selected master issues a start condition. This condition is followed by address frame and data frame. After the completion of data transfer master can generate stop condition.

Depending on the master or slave configuration various interrupts can be generated. For example, in master mode interrupt can be generated when transmit or receive operation is completed or when the data transfer is aborted due to an error. In slave mode interrupts can be generated when the data has been sent to or requested by the master.

2 Serial Peripheral Interface (SPI)

2.1 Introduction

SPI sometimes also known as four wire serial communication as it based on four lines, Clock, Data Input, Data Output, and Slave Select. The module enables to select between the three frame formats, Motorola SPI, National Semiconductor Microwire, or the Texas Instruments Synchronous Serial Interface. This communication is preferred whenever high-speed serial communication is required. Bit rate that can be achieved on the TM4C123GH6PM (microcontroller on Tiva LaunchPad) is from 2 Mbps to 25 Mbps. On PadmaBoard there is microSD card and TV output connected to the SPI pins. For TV output SPI protocol is not required, but it requires fast toggling of the GPIO which can be achieved easily on the SPI bus. Microcontroller on Tiva LaunchPad, TM4C123GH6PM has four such modules with various features mentioned below:

  • It can be configured for both master and slave operation.

  • It has programmable bit rate.

  • Separate transmit and receive FIFOs, each 16-bit wide and has 8 locations deep.

  • Programmable data frame size varying from 4- to 16-bits.

  • Various FIFO based interrupts and end of transmission interrupts.

2.2 Functional Description

This module performs parallel to serial data conversion before transmitting and serial to parallel data conversion on the received data. In SPI, master configures the clock which is supported by the slave device. The master generates the slave select signal, then with each clock cycle master sends the bit on data out line and receives a bit on data input line. In this way, full duplex communication is established between slave and master. Master can configure the clock polarity, which determines the idle state of clock and clock phase. Clock phase determines clock edge when the data bit is captured and transmitted by the module. There are four different modes, Mode0, Mode1, Mode2, and Mode3 which determines the clock polarity and clock phase.Footnote 3

Though in microcontroller on Tiva LaunchPad only one slave select pin is available per module. But the GPIOs can also be used as slave select pins which enable to use single SPI module configured in master mode for various slave devices. Figure 3 shows the block diagram containing one SPI master controlling multiple slaves. This type of configuration in which each slave has its own select line is independent slave configuration. Multiple slaves can be connected using daisy chain configuration as shown in Fig. 4. In this configuration, data out of master is connected to data input of slave and data output of first slave is connected to the data input of second slave, and so on. And, data output of last slave is connected to data input of the master. This whole chain acts as shift register and it requires only one select line.

Fig. 3
figure 3

Block diagram for SPI connection using independent slave configuration

Fig. 4
figure 4

Block diagram for SPI connection using daisy chain configuration

3 Experiment 48—Sine Wave Generator

3.1 Objective

Generate the sine wave using I2C based serial DAC.

3.2 Hardware Description

To perform this experiment serial I2C based 12-bit DAC is used to generate sine wave. Oscilloscope or data acquisition card is required to observe the sine waveform. PadmaBoard has two serial 12-bit DAC 7571, the address of both DACs are made unique by using external A0 (LSB of Address). Therefore, the addresses of two DACs are 0\(\times \)4C and 0\(\times \)4D (both the addresses are in hexadecimal). In this experiment, DAC with address 0\(\times \)4C is used whose output can be observed on connector X9. Figure 5 show the block diagram of the hardware setup for experiment. It uses I2C module 0, whose pin is multiplexed with GPIOs, PB2 and PB3 as shown in block diagram.

Fig. 5
figure 5

Block diagram for sine wave generator

3.3 Program Flow

In this experiment to generate sine wave, a lookup table is used. Look up table has 512 values containing 12-bit sine values (ranges from 0 to 4095) of one period. Since, only data need to be transmitted to DAC (there is no need to read the data from DAC). Hence, slave address and direction of flow of data will not change. So, there is no need to transfer address frame again and again. Only data frame needs to be transmitted from master to slave. So burst mode of I2C module can be used. In this mode, after start condition address frame is transmitted then bulk of data frames followed by stop condition to stop the transfer of data. Since, in burst mode address frame is not transmitted after each data frame, therefore DAC will be updated more frequently with new data. So, by using burst mode the frequency of sine wave achieved will be higher than frequency achieved during single send mode.Footnote 4 Since, in this experiment sine wave is generated continuously so there no need to stop transmitting the data to the serial DAC. Hence, in the program code burst send finish command is included after never ending loop so that the transmission of sine data values to DAC is continuous. That statement is included to show how to terminate burst transactions, although that statement is redundant for this experiment. The algorithm to perform the above experiment is mentioned below:

  1. 1.

    Enable the system clock, GPIO Port B, and I2C Module 0.

  2. 2.

    Configure the I2C module with appropriate configuration parameters and slave address.

  3. 3.

    Start the burst transaction. Read the 12-bit sine value from look up table and break it into 2 bytes to be transferred one after other.

  4. 4.

    Continue transmitting in the burst transaction mode.

The program flow for the experiment us shown in Fig. 6.

Fig. 6
figure 6

Program flow for sine wave generator

3.4 Useful API Function Calls

Useful API calls to perform the experiment involving I2C peripheral are mentioned below.

  1. 1.

    GPIOPinTypeI2C - It configures the pin(s) for I2C peripheral.

    Prototype: void GPIOPinTypeI2C(uint32_t ui32Port, uint8_t ui8Pins)

    Parameters: ui32Port is the base address of the GPIO port. ui8Pins is the bit-packed representation of the pin(s).

    Description: This function configures the pin(s) to be used as I2C pins only if they are muxed with the I2C peripheral.

    Returns: None.

  2. 2.

    GPIOPinTypeI2CSCL - It configures the pin(s) as SCL for I2C peripheral

    Prototype: void GPIOPinTypeI2CSCL(uint32_t ui32Port, uint8_t ui8Pins)

    Parameters: ui32Port is the base address of the GPIO port. ui8Pins is the bit-packed representation of the pin(s).

    Description: This function configures the pin(s) to be used as SCL pin of I2C peripheral, only if they are muxed with the SCL pin of I2C peripheral.

    Returns: None.

  3. 3.

    I2CMasterDisable - It disables the I2C master block.

    Prototype: void I2CMasterDisable(uint32_t ui32Base)

    Parameters: ui32Base is the base address of the I2C Master module.

    Description: This function disables operation of the I2C master block.

    Returns: None.

  4. 4.

    I2CMasterEnable - It enables the I2C master block.

    Prototype: void I2CMasterEnable(uint32_t ui32Base)

    Parameters: ui32Base is the base address of the I2C Master module.

    Description: This function enables operation of the I2C master block.

    Returns: None.

  5. 5.

    I2CMasterInitExpClk - It initializes the I2C Master block.

    Prototype: void I2CMasterInitExpClk(uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast)

    Parameters: ui32Base is the base address of the I2C Master module. ui32I2CClk is the clock supplied to the I2C module. bFast set up for fast data transfer.

    Description: This function initializes the I2C Master block by configuring the bus speed and enabling the master block. If the parameter bFast is true it set the I2C data transfer speed as 400 Kbps and if it false it set the speed as 100 Kbps. To enable Fast mode plus (1 Mbps) or High-Speed Mode (3.33 Mbps) user need to write into the registers manually.

    Returns: None.

  6. 6.

    I2CMasterSlaveAddrSet - Sets the address that the I2C Master places on the bus.

    Prototype: void I2CMasterSlaveAddrSet(uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)

    Parameters: ui32Base is the base address of the I2C Master module.ui8SlaveAddr is the 7-bit slave address. bReceive is the flag indicates whether to receive or transmit data to slave.

    Description: This function configures the slave address that I2C master places on the bus and communicates with the same. the flag bit bReceive, if it is true then it indicates master wants to read data from slave and if it is false master wants to write data to slave.

    Returns: None.

  7. 7.

    I2CMasterDataPut - It transmit the byte from I2C Master.

    Prototype: void I2CMasterDataPut(uint32_t ui32Base, uint8_t ui8Data)

    Parameters: ui32Base is the base address of the I2C Master module.ui8Data data to be transmitted from Master

    Description: This function transmits the data from the I2C master block.

    Returns: None.

  8. 8.

    I2CMasterControl - It controls the I2C Master block.

    Prototype: void I2CMasterControl(uint32_t ui32Base, uint32_t ui32Cmd).

    Parameters: ui32Base is the base address of the I2C Master module. ui32Cmd command issued to the I2C Master module.

    Description: This function controls the state of the operations of the I2C Master module. The parameter ui32Cmd can take the following commands.

    I2C_MASTER_CMD_SINGLE_SEND

    I2C_MASTER_CMD_SINGLE_RECEIVE

    I2C_MASTER_CMD_BURST_SEND_START

    I2C_MASTER_CMD_BURST_SEND_CONT

    I2C_MASTER_CMD_BURST_SEND_FINISH

    I2C_MASTER_CMD_BURST_SEND_ERROR_STOP

    I2C_MASTER_CMD_BURST_RECEIVE_START

    I2C_MASTER_CMD_BURST_RECEIVE_CONT

    I2C_MASTER_CMD_BURST_RECEIVE_FINISH

    I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP

    I2C_MASTER_CMD_QUICK_COMMAND

    I2C_MASTER_CMD_HS_MASTER_CODE_SEND

Returns: None.

3.5 Program Code

The complete C program for the experiment is given below. The program is well commented for better understanding purpose.

figure a
figure b

4 Experiment 49—Real Time Clock

4.1 Objective

Configure the real time clock to current time and date setting and keep printing the updated year, month, day, hour, minute, and seconds on UART terminal.

4.2 Hardware Description

This experiment requires RTC. On PadmaBoard, RTC used is PCF8563 of NXP Semiconductors. The block diagram for the experiment is shown in Fig. 7. This RTC uses I2C module 0 on PadmaBoard whose pins are multiplexed with GPIOs PB2 and PB3. On PadmaBoard, RTC is powered with 3V coin cell in addition to 3.3 V coming from board, so that when the power is turned off, RTC will remain powered and updating the present date and time.Footnote 5

4.3 Program Flow

Real time clock, PCF8563 has the slave address 0x51. The algorithm to perform the experiment is as follows:

  1. 1.

    Enable the system clock, GPIO Port A, GPIO Port B, UART Module 0 and I2C Module 0.

  2. 2.

    Configure the UART and I2C modules with appropriate configuration parameters.

  3. 3.

    Setup the RTC with current date and time which include second, minute, hour, day, weekday, month, and year. Since while setting up the I2C many data need to be written into the RTC registers, so for this burst transaction mode can be used.

  4. 4.

    Send the address of registers needed to read for updated parameters of date and time (like seconds, minutes, hours, day, weekday, month and year) and read back the corresponding register values.

  5. 5.

    Print the updated time and date value on the UART Terminal on host PC.

Figure 8 refers the program flow of experiment.

Fig. 7
figure 7

Block diagram for real time clock

Fig. 8
figure 8

Program flow for real time clock

5 Experiment 50—Alarm Clock

5.1 Objective

Set alarm in RTC to trigger at a particular time and day. When the alarm is triggered use buzzer to indicate it.

5.2 Hardware Description

This experiment requires RTC and buzzer to perform it. The block diagram of experiment is shown in Fig. 9. In this experiment, configure the RTC to trigger the alarm for a particular time and day. At that particular time and day RTC will generate the interrupt. Interrupt line is multiplexed with keypad scan input line connected to GPIO PE0. So if some application requires the use of both RTC and Keypad, application user will have intelligently handle the situation while writing the application code.Footnote 6 Once the interrupt is generated buzzer should be triggered.

Fig. 9
figure 9

Block diagram for alarm clock

5.3 Experiment Tips

In this experiment, alarm time and day is hard coded in the application. The same can be taken as input from user through UART terminal on host PC, so that user need not to change the code again and again while setting the alarm.

6 Experiment 51—Twilight Calculator

6.1 Objective

Use RTC to determine the twilight times of the present entire week and display it on UART terminal on host PC.

6.2 Hardware Description

To perform this experiment, RTC is required to keep track of present date and time. And based on this determine twilight times for the entire week. The block diagram for hardware description is same as discussed in experiment RTC.

7 Experiment 52—Sun Tracker

7.1 Objective

Use RTC to track position of the Sun and display it on UART Terminal on host PC.

7.2 Hardware Description

To perform this experiment the hardware requirement is same as discussed in experiment Real Time Clock. As to perform this experiment RTC is required to determine the current date and time as position of Sun depends on this factor. Also, position of Sun depends on the latitude and longitude of location.

8 Experiment 53—High Frequency Sine Wave Generator

8.1 Objective

Use I2C in Fast Mode Plus (1 Mbps) or High-Speed Mode (3.3 Mbps) to generate sine wave with more frequency than in previous experiment.

8.2 Hardware Description

The hardware requirement for this experiment is same as experiment sine wave generator as discussed earlier.

9 Experiment 54—Lissajous Figures

9.1 Objective

Generate the basic Lissajous figures: circle, ellipse, and line on the oscilloscope.

9.2 Hardware Description

This experiment requires two DACs and the oscilloscope which has more than two channels and support X-Y mode. The block diagram for experiment is shown in Fig. 10. The two DACs used on PadmaBoard are I2C based DAC7571 with slave addresses 0\(\times \)4C and 0\(\times \)4D. The output of both DACs can be observed on connectors X9 and X10, respectively. Connect these outputs to two channels of the oscilloscope and use oscilloscope in X-Y mode.

Fig. 10
figure 10

Block diagram for Lissajous figures

9.3 Experiment Tips

For better plot on oscilloscope use I2C in Fast Mode Plus or High-Speed Mode. As this experiment uses the concept of persistence of vision, as when signal is given to X and Y channel, then at particular instant only one point will be plotted on the oscilloscope. So, to generate the figure, move the point fast enough corresponding to that figure, so that due to persistence of vision, desired figure is observed on the oscilloscope. To plot the circle generate sine wave on one DAC output and generate cosine (or sine with 90 degree phase shift) of same amplitude on the second DAC. To plot the eclipse generate sine and cosine wave of different amplitudes. And for the line, establish a linear relation between analog outputs of two DACs.

10 Experiment 55—Oscilloscope Clock

10.1 Objective

Read current time from RTC and display it on the oscilloscope as an analog clock.

Fig. 11
figure 11

Block diagram for oscilloscope clock

10.2 Hardware Description

This experiment requires RTC to determine real time, and two DACs to generate the analog clock on the oscilloscope. Figure 11 shows the block diagram for hardware description of experiment. Analog clock on the oscilloscope can be simulated by using the same concept of experiment Lissajous Figures.

11 Experiment 56—Classic Brick Game

11.1 Objective

Develop the classic brick game on the oscilloscope. Use switch SW1 and SW2 on Tiva LaunchPad as control buttons.

11.2 Hardware Description

To perform this experiment two push buttons and two DACs are required. Two push buttons are on Tiva LaunchPad and 2 DACs are on PadmaBoard. The block diagram for the hardware description is shown in Fig. 12.

Fig. 12
figure 12

Block diagram for classic Brick game

11.3 Experiment Tips

This experiment is similar to experiment implementation of Lissajous Figure but in this the image will be moving. Like to move a circle on the oscilloscope keep shifting the origin of circle after certain interval. In this way, figure with dynamic motion will be generated on the oscilloscope.

12 Experiment 57—Chaos

12.1 Objective

Plot a chaotic map on the oscilloscope. There are various chaotic maps having quite complex mathematical relations. Presence of floating point unit can be put to test by performing this experiment.

12.2 Hardware Description

The hardware requirement for this experiment is same as for the experiment Lissajous figures.

13 Experiment 58—Tiva on TV

13.1 Objective

Print custom message on the television using composite channel.

13.2 Hardware Description

The hardware of this experiment is pretty simple. It requires two resistors of 450 and 900 ohm and a female RCA connector. Generic resistor values available in market, close to mentioned values are 470 and 1000 ohm. These values of resistor will also work. Plug the cable between TV video input and RCA connector on PadmaBoard as video signal is generated in this experiment and want to observe it on TV. The block diagram of experiment is shown in Fig. 13. Television unit has internal 75 ohm of resistance, so combination of mentioned three resistance form 2-bit DAC. Also PD1 is multiplexed with potentiometer using the jumper, JP1. So place the jumper connection appropriately to select TV output.

Fig. 13
figure 13

Block diagram for Tiva on TV

13.3 Experiment Tips

The image consists of scan lines, each scan line is of 64 us. In beginning of the scan first horizontal sync pulse is sent for approximately 4 us. Then, some delay is generated for approximately 8 us, and data is transferred after that for the next 52 us. The time of horizontal pulse and delay varies from one TV to another as older ones will be having more delay. Use the systick timer interrupt which will be generating interrupts at every 64 us. Use the VGA font header file to have the character input. During sync keep both lines at logic low. For black, keep the PD1 at logic high and PD3 at logic low, and for white color keep both at logic high. Output on TV will be black and white, so for this PD1 will remain at logic high whereas PD3 will be toggling. Hence, to toggle PD3, use it as SPI data out to achieve high-toggling rate upto 25 Mbps. It is quite time-consuming experiment. Refer to detailed working and generation of TV video signals before performing this experiment. Also, optimize the code using option Optimize Size (-Os) in GCC compiler.

14 Experiment 59—Weather Channel

14.1 Objective

Use temperature sensor to sense the temperature and display temperature on television screen.

14.2 Hardware Description

This experiment requires a temperature sensor in addition to the hardware described in previous experiment. On PadmaBoard use LM35 as temperature sensor. The block diagram for hardware description of experiment is shown in Fig. 14. Also, place the jumper connections appropriately at JP1 and JP6.

Fig. 14
figure 14

Block diagram for weather channel

15 Experiment 60—Hello SD Card!

15.1 Objective

Interface microSD card with Tiva LaunchPad and on pressing switch SW1, generate text file in microSD card. The text file should contain the “Hello World” message in it.

15.2 Hardware Description

To perform this experiment switch, microSD card holder, and a microSD card are required. MicroSD works on the SPI protocol. Already, a lot of experiments have been discussed earlier on usage the switch, SW1 present on the Tiva LaunchPad. The hardware block diagram of the experiment is shown in Fig. 15.

Fig. 15
figure 15

Block diagram for hello SD card!

15.3 Experiment Tips

Download the libraries of the microSD card, may require to tweak them a little bit to include the SPI function calls used in programming Tiva C Series microcontrollers. Also, change the optimization setting from none to “Optimize Size (-Os)”. Also, may need to unchecked the “Do not use default libraries” and “Do not use the standard start files” option before building this project.

16 Experiment 61—Temperature Recorder

16.1 Objective

In this experiment whenever switch (SW1) is pressed, current ambient temperature will be stored in microSD card.

16.2 Hardware Description

To perform this experiment switch (SW1), LM35 to sense the temperature, and microSD card interface to store the data is required. The block diagram to perform this experiment is shown in Fig. 16. Place jumper connections appropriately on jumper, JP6 to select temperature sensor, LM35.

Fig. 16
figure 16

Block diagram for temperature recorder

16.3 Experiment Tips

In this experiment, wait for SW1, to press, once it is pressed sample the analog channel corresponding to temperature sensor. Convert the sensor data into temperature in degree celsius value. Open temperature recorder text file and store the temperature value in that text file. After storing it in text file close the file and wait for the switch to be pressed again.

17 Experiment 62—Temperature Logger

17.1 Objective

Use RTC to keep logging temperature values in the text file in microSD card after certain interval. Use switch, SW1 to finish the experiment and close the file.

17.2 Hardware Description

To perform this experiment use RTC for time stamping purpose, LM35 to sense temperature, microSD card interface to log temperature data in text file and switch SW1 to close the text file and finish the experiment. The block diagram to illustrate hardware associated with experiment is shown in Fig. 17.

Fig. 17
figure 17

Block diagram for temperature logger

18 Experiment 63—Voice Recorder

18.1 Objective

Start recording the audio input from microphone once the switch SW1 is pressed in microSD card. Once the switch SW2 is pressed stop the recording and start audio playback of recorded audio on 3.5 mm audio jack through the DAC 7571.

18.2 Hardware Description

This experiment requires two switches, SW1 and SW2, one electret microphone for audio input, microSD card interface to store audio input and DAC along with 3.5 mm audio jack at its output to play back the recorded audio. Figure 18 shows the block diagram of hardware description for experiment.

Fig. 18
figure 18

Block diagram for voice recorder

18.3 Experiment Tips

Once the switch SW1 is pressed open a text file in microSD card and start recording the ADC values which are sampled from channel where microphone is connected. Recorded ADC values are stored in text file in microSD card. Try to sample the audio data from ADC as fast as possible. Once, switch SW2 is pressed start reading the analog values from the text file and pass those values to DAC7571, whose analog output is connected to 3.5 mm audio jack. Connect earphones or speaker on the audio jack for audio output.

19 Experiment 64—WAV Player

19.1 Objective

Store the audio files (.wav format) in microSD card and read these audio files and play it using 3.5 mm audio jack. Use two switches present on Tiva LaunchPad to move to next or previous song.

19.2 Hardware Description

The hardware required to perform this experiment is 2 switches to select the previous or next audio file, microSD card to store the audio files (in .wav format) and DAC 7571 with its output connected to 3.5 mm audio jack to play audio files. Figure 19 shows the block diagram representing hardware description for the experiment.

Fig. 19
figure 19

Block diagram for voice recorder

19.3 Experiment Tips

Go through the format of .wav files thoroughly before performing this experiment. Read .wav file, in the beginning it contains useful information such as file size, length of the data, sample rate, bits per sample, etc and after that it contains the data. The initial information in the .wav file is important as it helps in reading the data. Also, DAC used is serial DAC so for better response use the audio files with sample rate of 22,050 Hz. Use the I2C in fast mode plus or high-speed mode.