NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
StarterWare enables audio input and output via the Multichannel Audio Serial Port (McASP) peripheral. The McASP module is a serial port optimized for multi-channel audio applications. McASP supports time division multiplexed (TDM) streams, Inter-IC Sound (I2S) protocols, and inter component digital audio interface transmission (DIT). McASP has separate transmit and receive units that can operate synchronously or independently. McASP can be configured for external or internal clock and frame sync signals. StarterWare examples configure McASP as slave. McASP has 16 serialisers, each of which can be configured as a transmitter or a receiver. The StarterWare APIs to configure and operate McASP are listed in include/mcasp.h.
The McASP exchanges audio data with a codec that is connected to the McASP through data, clock, and frame sync lines. The codec is configured separately through the control bus (typically I2C or SPI). Prior to using the McASP for audio applications, the user must make the following design decisions:
- Pin settings - The McASP pins must be configured to operate in McASP mode. Also, if external clock/frame sync signals are to be used, respective pins must be configured as input pins. All the serializers that are transmitters must be configured as output pins, and all serializers that are receivers must be configured as input pins.
- Sampling rate - The clock and frame sync sources for the transmit and receive sections must be configured based on the desired sampling rate.
- Data format - Depends on the word size, slot size, and the protocol to be supported.
- Data transfer mode - Based on the application, the McASP must be configured for the mode of data transfer. Data can be handled using DMA, or interrupts/polling can be used to monitor the status bits.
The McASP can be initialized for separate transmit/receive sections. General programming guidelines for McASP are given below.
- Configure the McASP pins using McASPPinMuxSetup() and enable the PSC for McASP.
- Configure the audio codec which is connected to the McASP based on the clock/frame sync and data format settings via the control bus.
- Reset the McASP Transmit/Receive sections using McASPTxReset() or McASPRxReset().
- If DMA mode of operation is intended, enable the Write FIFO using McASPWriteFifoEnable() for transmission and enable the Read FIFO using McASPReadFifoEnable() for reception.
- Set the data format using the McASPTxFmtMaskSet()/McASPRxFmtMaskSet() APIs and McASPTxFmtSet()/McASPRxFmtSet() APIs separately for transmit and receive sections, respectively. For I2S mode, McASPTxFmtI2SSet()/McASPRxFmtI2SSet() can be used instead.
- Configure the frame sync signal for transmit/receive sections using the McASPTxFrameSyncCfg()/McASPRxFrameSyncCfg() APIs. The frame sync source can be selected to be internal or external.
- Configure the bit clock for the transmit/receive sections using McASPTxClkCfg()/McASPRxClkCfg(). The clock source can be internal, external, or mixed.
- Select the polarity of the bit clock for transmission using McASPTxClkPolaritySet(). If the external receiver samples data on the rising edge, the McASP transmitter must shift the data out during the falling edge of the clock (or vice versa). The polarity of bit clock for reception must be selected using McASPRxClkPolaritySet(). If the external transmitter shifts the data out during the rising edge of the clock, the McASP receiver must sample the data during the falling edge of the clock (or vice versa).
- Select the time slots during which transmission/reception must happen using the McASPTxTimeSlotSet()/McASPRxTimeSlotSet() APIs.
- Set the desired serializers as transmitters/receivers using McASPSerializerTxSet()/McASPSerializerRxSet().
- Configure the McASP pins to be used for McASP using McASPPinMcASPSet().
- Configure the pin directions of the output and input pins using McASPPinDirOutputSet()/McASPPinDirInputSet().
- Start the transmitter/receiver clock by invoking the McASPTxClkStart()/McASPRxClkStart() APIs.
- If DMA mode of transfer is to be used, enable the DMA transfer at this step. If interrupt mode of transfer is to be used, enable the interrupts here using the McASPTxIntEnable()/McASPRxIntEnable() APIs.
- Activate the transmit/receive serializers by invoking McASPTxSerActivate()/McASPRxSerActivate().
- If CPU polling mode/interrupt mode is used, write the TX buffer at this step using the McASPTxBufWrite() API.
- Enable the transmit/receive state machine and frame sync by invoking McASPTxEnable()/McASPRxEnable() APIs.
- If CPU polling method/interrupt method is used, before putting data into the transmit buffer and before reading data from the receive buffer, the data ready bit must be polled using the McASPTxStatusGet()/McASPRxStatusGet() APIs.