English
Language : 

SGTL5000XNAA3R2 Datasheet, PDF (29/68 Pages) Freescale Semiconductor, Inc – Low Power Stereo Codec with Headphone Amp
FUNCTIONAL DEVICE OPERATION
PROGRAMMING EXAMPLES
END-USER DRIVEN CHIP CONFIGURATION
End-users control features like volume up/down, and
audio EQ parameters such as Bass and Treble. This requires
programming the chip without introducing any pops/clicks or
any other disturbance to the output. This section shows
examples on how to program these features.
VOLUME AND MUTE CONTROL
Refer to Volume Control for examples on how to program
volume when end-user changes the volume or mutes/
unmutes the output. Note that the DAC volume ramp is
automatically handled by the chip.
7-BAND PEQ PRESET SELECTION
This programming example shows how to load the filter
coefficients when the end-user changes PEQ presets such
as Rock, Speech, Classical etc.
// Load the 5 coefficients for each band and write them to
// appropriate filter address. Repeat this for all enabled
// filters (this example shows 7 filters)
for (i = 0; i < 7; i++)
{
// Note that each 20-bit coefficient is broken into 16-bit MSB
// (unsigned short usXXMSB) and 4-bit LSB (unsigned short
// usXXLSB)
Write DAP_COEF_WR_B0_LSB usB0MSB[i]
Write DAP_COEF_WR_B0_MSB usB0LSB[i]
Write DAP_COEF_WR_B1_LSB usB1MSB[i]
Write DAP_COEF_WR_B1_MSB usB1LSB[i]
Write DAP_COEF_WR_B2_LSB usB2MSB[i]
Write DAP_COEF_WR_B2_MSB usB2LSB[i]
Write DAP_COEF_WR_A1_LSB usA1MSB[i]
Write DAP_COEF_WR_A1_MSB usA1LSB[i]
Write DAP_COEF_WR_A2_LSB usA2MSB[i]
Write DAP_COEF_WR_A2_MSB usA2LSB[i]
// Set the index of the filter (bits 7:0) and load the
// coefficients
Modify DAP_FILTER_COEF_ACCESS->INDEX (0x0101 + i)
// bit 8
}
5-BAND GEQ VOLUME CHANGE
This programming example shows how to program the
GEQ volume when end-user changes the volume on any of
the 5 bands.
GEQ volume should be ramped in 0.5 dB steps in order to
avoid any pops. The example assumes that volume is
ramped on Band 0. Other bands can be programmed
similarly.
// Read current volume set on Band 0
usCurrentVol = Read DAP_AUDIO_EQ_BASS_BAND0
// Convert the new volume to hex value
usNewVol = 4*dNewVolDb + 47;
// Calculate the number of steps
Analog Integrated Circuit Device Data
Freescale Semiconductor
usNumSteps = abs(usNewVol - usCurrentVol);
if (usNumSteps == 0) return;
for (int i = 0; i++; usNumSteps)
{
if (usNewVol > usCurrentVol)
++usCurrentVol;
else
--usCurrentVol;
Write DAP_AUDIO_EQ_BASS_BAND0 usCurrentVol;
}
TONE CONTROL - BASS AND TREBLE CHANGE
This programming example shows how to program the
Tone Control Bass and Treble when end-user changes it on
the fly.
Tone Control Bass and Treble volume should be ramped
in 0.5 dB steps in order to avoid any pops. The example
assumes that Treble is changed to a new value. Bass can be
programmed similarly.
// Read current Treble value
usCurrentVal = Read DAP_AUDIO_EQ_TREBLE_BAND4
// Convert the new Treble value to hex value
usNewVol = 4*dNewValDb + 47;
// Calculate the number of steps
usNumSteps = abs(usNewVal - usCurrentVal);
if (usNumSteps == 0) return;
for (int i = 0; i++; usNumSteps)
{
if (usNewVal > usCurrentVal)
++usCurrentVal;
else
--usCurrentVal;
Write DAP_AUDIO_EQ_TREBLE_BAND4 usCurrentVal;
}
FREESCALE SURROUND ON/OFF
This programming example shows how to program the
Surround when end-user turns it on/off on their device.
The Surround width should be ramped up to highest value
before enabling/disabling the Surround to avoid any pops.
// Read current Surround width value
// WIDTH_CONTROL bits 6:4
usOriginalVal = (Read DAP_SGTL_SURROUND >> 4) &&
0x0003;
usNextVal = usOriginalVal;
// Ramp up the width to maximum value of 7
for (int i = 0; i++; (7 - usOriginalVal)
{
++usNextVal;
Modify DAP_SGTL_SURROUND->WIDTH_CONTROL
usNextVal;
}
// Enable (To disable, write 0x0000) Surround
SGTL5000
29