EVM6418 AIC23 Module
The codec module include file evm6418_aic23.h contains constant definitions for the handles and AIC23 register offsets. Please view it to see what definitions are available.
The following list summarizes the AIC23 Codec API in terms of its function calls:
AIC23 Codec Registers
The AIC23 has 10 registers that control functions such as volume, data formats, sample rates and power down modes. The registers are written to through the control channel on McBSP1. Register definitions are taken from the AIC23 datasheet ( tlv320aic23.pdf ) for quick reference.
AIC23 Codec Register Definitions

0 - Left Input Volume (EVM6418_AIC23_LEFTINVOL)
1 - Right Input Volume (EVM6418_AIC23_RIGHTINVOL)
2 - Left Headphone Volume (EVM6418_AIC23_LEFTHPVOL)
3 - Right Headphone Volume (EVM6418_AIC23_RIGHTHPVOL)
4 - Analog Audio Path Control (EVM6418_AIC23_ANAPATH)
5 - Digital Audio Path Control (EVM6418_AIC23_DIGPATH)
6 - Power Down Control (EVM6418_AIC23_POWERDOWN)
7 - Digital Audio Interface Format (EVM6418_AIC23_DIGIF)
8 - Sample Rate Control (EVM6418_AIC23_SAMPLERATE)

9 - Digital Interface Activation (EVM6418_AIC23_DIGACT)
15 - Reset Register (EVM6418_AIC23_RESET)
EVM6418_AIC23_openCodec()
Description
Initialize the AIC23 codec module and perform codec setup. Must be called before any other AIC23 functions.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
EVM6418_AIC23_CodecHandle EVM6418_AIC23_openCodec(Int16 id, EVM6418_AIC23_Config *Config, Int16 direction)
Parameters
id - Specifies which codec to use, on the EVM6418, id = 0.
Config - Pointer to structure containing codec register values. The function will initialize the codec registers with the values in the structure.
direction – Flags (EVM6418_AIC23_INPUT and EVM6418_AIC23_OUTPUT) that determine if the McASP should be opened for input, output or both. To open the McASP in both directions, logically or together the INPUT and OUTPUT flags.
Return Value
Handle for the codec on success, the CSL constant INV (equal to –1) on fail. The only failure condition is if the McASP is already in use.
Example
/* Codec configuration settings */
EVM6418_AIC23_Config config = {
0x0017, // 0 EVM6418_AIC23_LEFTINVOL Left line input volume
0x0017, // 1 EVM6418_AIC23_RIGHTINVOL Right line input volume
0x00d8, // 2 EVM6418_AIC23_LEFTHPVOL Left headphone volume
0x00d8, // 3 EVM6418_AIC23_RIGHTHPVOL Right headphone volume
0x0011, // 4 EVM6418_AIC23_ANAPATH Analog audio path CTRL
0x0000, // 5 EVM6418_AIC23_DIGPATH Digital audio path CTRL
0x0000, // 6 EVM6418_AIC23_POWERDOWN Power down control
0x0043, // 7 EVM6418_AIC23_DIGIF Digital audio interface
0x0081, // 8 EVM6418_AIC23_SAMPLERATE Sample rate control
0x0001 // 9 EVM6418_AIC23_DIGACT Digital intf activation
};
/* Open codec with default settings */
EVM6418_AIC23_CodecHandle hCodec;
hCodec = EVM6418_AIC23_openCodec(0, &config,
EVM6418_AIC23_INPUT | EVM6418_AIC23_OUTPUT);
EVM6418_AIC23_closeCodec()
Description
Close the AIC23 codec
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_closeCodec( EVM6418_AIC23_CodecHandle hCodec )
Parameters
hCodec - Codec handle
Return Value
None
Example
/* Close the AIC23 Codec */
EVM6418_AIC23_closeCodec( hCodec )
EVM6418_AIC23_config()
Description
Change the codec configuration. Use to set volume, enable mute, etc.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_config( EVM6418_AIC23_CodecHandle hCodec, EVM6418_AIC23_Config *Config )
Parameters
hCodec - Codec handle
config - Pointer to structure containing codec register values. The function will initialize the codec registers with the values in the structure.
Return Value
None
Example
/* AIC23 codec settings -
* each entry below represents an AIC23 register */
EVM6418_AIC23_Config config = {
0x0017, // 0 EVM6418_AIC23_LEFTINVOL Left line input volume
0x0017, // 1 EVM6418_AIC23_RIGHTINVOL Right line input volume
0x00d8, // 2 EVM6418_AIC23_LEFTHPVOL Left headphone volume
0x00d8, // 3 EVM6418_AIC23_RIGHTHPVOL Right headphone volume
0x0011, // 4 EVM6418_AIC23_ANAPATH Analog audio path CTRL
0x0000, // 5 EVM6418_AIC23_DIGPATH Digital audio path CTRL
0x0000, // 6 EVM6418_AIC23_POWERDOWN Power down control
0x0043, // 7 EVM6418_AIC23_DIGIF Digital audio interface
0x0081, // 8 EVM6418_AIC23_SAMPLERATE Sample rate control
0x0001 // 9 EVM6418_AIC23_DIGACT Digital intf activation
};
/* Configure codec with defaults
* except mute bit set( bit 3 of reg 5 ) */
EVM6418_AIC23_config( hCodec, &config );
EVM6418_AIC23_read()
Description
Read a 32 bit value from the codec data port.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
Int16 EVM6418_AIC23_read(EVM6418_AIC23_CodecHandle hCodec, Uint32 *val)
Parameters
hCodec - Codec handle
val - Address of 32 bit variable to receive codec data. Left channel in lower 16-bits, right channel in upper 16-bits.
Return Value
TRUE – Data written successfully.
FALSE – Data port is busy.
Example
Uint16 data;
/* Read 32 bits of codec data,
* loop to retry if data port is busy */
while(!EVM6418_AIC23_read16(hCodec, &data));
EVM6418_AIC23_write()
Description
Write a 32 bit value to the codec data port.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
EVM6418_AIC23_write( EVM6418_AIC23_CodecHandle hCodec, Int16 val )
Parameters
hCodec - Codec handle
val - 32 bit value to write to codec. Left channel in lower 16-bits, right channel in upper 16-bits.
Return Value
TRUE – Data written successfully.
FALSE – Data port is busy.
Example
Uint32 data = 0x12345678;
/* Write 0x12345678 to the codec,
* loop to retry if data port is busy */
while(!EVM6418_AIC23_write(hCodec, data));
EVM6418_AIC23_rset()
Description
Set the value of a codec control register
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_rset( EVM6418_AIC23_CodecHandle hCodec, Uint16 regnum, Uint16 regval )
Parameters
hCodec - Codec handle
regnum - Which codec register to set
regval - Value to set the register to
Return Value
None
Example
/* Set codec left and right gain to 0x79 */
EVM6418_AIC23_rset(hCodec, 2, 0x79);
EVM6418_AIC23_rset(hCodec, 3, 0x79);
EVM6418_AIC23_rget()
Description
Return the value of a codec register
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
Uint16 EVM6418_AIC23_rget( EVM6418_AIC23_CodecHandle hCodec, Uint16 regnum )
Parameters
hCodec - Codec handle
regnum - Which codec register to read
Return Value
16-bit register value
Example
Uint16 value;
/* Read codec register 1 */
value = EVM6418_AIC23_rget(hCodec, 1);
EVM6418_AIC23_outGain()
Description
Set the codec output gain. The gain is a 7 bit value that corresponds directly to the 7-bit gain field in the codec registers 2 and 3.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_outGain( EVM6418_AIC23_CodecHandle hCodec, Uint16 outGain )
Parameters
hCodec - Codec handle
outGain - Codec gain, 0 = lowest output, 0x7f = highest output
Return Value
None
Example
/* Set output gain to 0x79 */
EVM6418_AIC23_outGain( hCodec, 0x79 );
EVM6418_AIC23_loopback()
Description
Enable/disable the codec loopback mode. Loopback mode forces the codec to copy its input directly to its output. It is the opposite of a loopback cable that would copy the output back the input.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_loopback( EVM6418_AIC23_CodecHandle hCodec, Uint16 mode )
Parameters
hCodec - Codec handle
mode - Loopback mode enable (TRUE) or disable (FALSE)
Return Value
None
Example
/* Enable codec loop back mode */
EVM6418_AIC23_loopback( hCodec, 1 );
EVM6418_AIC23_mute()
Description
Enable/disable codec mute mode
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_mute( EVM6418_AIC23_CodecHandle hCodec, Uint16 mode )
Parameters
hCodec - Codec handle
mode - Codec mute enable (TRUE) or disable (FALSE)
Return Value
None
Example
/* Disable codec mute mode. */
EVM6418_AIC23_mute( hCodec, FALSE );
EVM6418_AIC23_powerDown()
Description
Enable/disable the codec powerdown modes.
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_powerDown( EVM6418_AIC23_CodecHandle hCodec, Uint16 sect )
Parameters
hCodec - Codec handle
sect - Bitmap of which sections to enable powerdown mode. Matches bits in the AIC23 Power Down Control register. Powerdown modes for a particular codec section are enabled if its corresponding bit is 1. Writing 0 as sect turns disables all powerdown modes (all sections are on).
Return Value
None
Example
/* Enable the ADC power down mode. */
EVM6418_AIC23_powerDown( hCodec, 0x04 );
EVM6418_AIC23_setFreq()
Description
Set the codec sample rate frequency
Required Headers
evm6418.h
evm6418_aic23.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_AIC23_setFreq( EVM6418_AIC23_CodecHandle hCodec, Uint32 freq )
Parameters
hCodec - Codec handle
freq - Sample rate of the codec clock. Can be one of the following, default is 48KHz, If an invalid frequency is entered no change will be made
EVM6418_AIC23_FREQ_8KHZ = 8,000 Hz
EVM6418_AIC23_FREQ_16KHZ = 16,000 Hz
EVM6418_AIC23_FREQ_24KHZ = 24,000 Hz
EVM6418_AIC23_FREQ_32KHZ = 32,000 Hz
EVM6418_AIC23_FREQ_44KHZ = 44,000 Hz
EVM6418_AIC23_FREQ_48KHZ = 48,000 Hz
EVM6418_AIC23_FREQ_96KHZ = 96,000 Hz
Return Value
None
Example
/* Set codec frequency to 48kHz */
EVM6418_AIC23_setFreq( hCodec, EVM6418_AIC23_FREQ_48KHZ );
|