Electronic

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

In embedded systems, there is an increasing need to provide high-fidelity audio instead of buzzers for user feedback, including alarms and alarms. While beeps or beeps have been effective in the past, users expect advanced sounds that can only be produced by playing audio in file formats such as MP3. The problem is, audio playback can be stressful and add cost and complexity to the system. The first instinct is to find a microcontroller that can play MP3s, but this often adds a few dollars to the bill of materials (BOM) and requires fairly complex embedded software.

In embedded systems, there is an increasing need to provide high-fidelity audio instead of buzzers for user feedback, including alarms and alarms. While beeps or beeps have been effective in the past, users expect advanced sounds that can only be produced by playing audio in file formats such as MP3. The problem is, audio playback can be stressful and add cost and complexity to the system. The first instinct is to find a microcontroller that can play MP3s, but this often adds a few dollars to the bill of materials (BOM) and requires fairly complex embedded software.

Audio codecs are one solution that balances extra cost and software complexity in particular. Audio codecs not only accept audio data streams from microcontrollers, they often have multiple functions that allow developers to fine-tune the audio playback system to improve the quality of the system playback.

This article will discuss the role of audio codecs, the main features developers should consider when choosing, and how to use them effectively. This article will introduce and explain the solutions of AKM semiconductor, Texas Instruments and Maxim Integrated as examples, and also introduce the solutions of other manufacturers. Finally, tips and tricks on how to use codecs to speed up the development of audio playback applications and reduce system costs will be presented.

What is an audio codec?

An audio codec is a hardware component capable of encoding or decoding a digital data stream containing audio information1. Audio codecs are useful because they offload audio processing from the microcontroller. This can greatly reduce software complexity, and can also use lower cost, lower performance microcontrollers in specific applications.

A typical audio codec will contain several functional blocks:

An I2S interface for transmitting or receiving encoded digital audio data.
An I2C interface for configuring and reading the audio codec’s control registers.
A microphone input connected to an analog-to-digital converter (ADC).

At least one audio output channel, such as a speaker output, but most also include a line output and possibly multiple speaker outputs for stereo playback.
A digital function block containing high pass, low pass, notch and equalizer filters for adjusting audio playback and recording.

Let’s take AKM Semiconductor’s AK4637EN 24-bit audio codec as an example, a popular audio codec for its low cost and powerful audio capabilities (Figure 1). The AK4637EN has all these features and also has a buzzer input that can generate a buzzer using a pulse width modulated (PWM) signal of the desired frequency.

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

Developers will find that the main difference between audio codecs is the ability to output mono or stereo audio, and digital block functionality. For example, the AK4637EN incorporates a high-pass filter, a low-pass filter, a four-band equalizer, an auto-level channel function, and a one-band equalizer. The latter can be used as a notch filter. How the developer sets up these digital filters can greatly affect the sound of the system.

Developers new to audio playback can sometimes be intimidated by audio codecs. For example, while the AK4637EN is a simple audio codec, a quick look at the datasheet reveals that it has 64 configurable registers. At first glance it may seem like a lot, but most of these registers are used to set the filter coefficients of the various digital filters available. To make the system output audio normally, only a few registers are needed, which makes the driver development of the audio codec much simpler than the novice thinks.

How to choose an audio codec

During product development, one of the key factors in selecting any device is cost, and audio codecs are no exception. It’s important to keep in mind, though, that developers get what they get for their money, so when it comes to audio, the team must carefully weigh the design requirements against the key parameters of the solution.

The first consideration is the output requirements of the audio codec. There are several different options. For example, the AK4637EN has one line output and one mono speaker output. There are other codecs, such as the TLV320AIC3110IRHBR stereo audio codec from Texas Instruments, which can drive two speakers at 1.29 W (Figure 2).

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

Other audio codecs, such as the Maxim Integrated MAX9867, are designed to drive only one pair of headphones (Figure 3). The MAX9867 has a typical I2S and I2C digital interface, and also includes a stereo microphone input and two digitally selectable line inputs.

In all three solutions, determining what output type (or even input type) to take is a key decision early on.

Developers also need to consider what loads they will be driving. Will the audio codec directly drive headphones, a speaker or a pair of speakers, and at what output level? If the system is going to drive a 5 W speaker, not many codecs for embedded systems can do that. Instead, developers may wish to select line outputs and use a separate Class D amplifier to drive the speakers directly. This saves some cost and allows for design flexibility.

The last two considerations are internal wiring and digital filtering capabilities. This is where the real differentiation and cost difference is determined for audio codec implementation. For example, the TLV320AIC311IRHBR features de-pop and soft-start to minimize speaker pop and smooth the transition to audio playback. Each output channel of the device is also equipped with an internal mixer and digital faders.

Developers should carefully balance audio codec requirements, BOM, and board space required for the circuit.

Audio playback system

When working with audio codecs, it is important to consider that there are several different functional blocks in addition to audio codecs that are required for successful audio playback. The specific functional blocks will be slightly different depending on the application and the playback method decided to take. Figure 4 is just an overview.

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

There are several points worth discussing in this graph. First, there needs to be some way to store the audio playback files. There are two options, one is to store the file internally, i.e. in the microcontroller flash memory, or the other is external flash memory. How to choose depends on the size of the audio file, and the internal flash memory capacity of the microcontroller.

Developers also need to consider what audio playback format to use. The most common format is MP3. In this case, the chosen microcontroller needs to have a software stack that supports MP3 decoding. This opens the MP3 file and pushes the audio signal out over the I2S interface using the Dynamic Memory Access (DMA) controller. Even the I2S port can be configured as master/slave and several other modes, so double-checking is required to ensure data is being transferred to the codec at the correct rate.

As mentioned earlier, the need for an external audio amplifier depends on the application. Typical codec output power is around 1 – 1.5 W, which is useful for driving small speakers. If you want to drive 3 W or higher speakers, you will need an external amplifier. Again, the most widely used are Class D audio amplifiers. The amplifier also does not necessarily need to have variable gain. The audio codec can digitally adjust the fader to provide a wide output power range.

One aspect that is often overlooked is bulk capacitors. When playing audio, it pulls the power rails badly. If there is not enough capacitor on the board, it will greatly affect the output quality, and there will be a nasal-like sound and some other unwanted noise. During testing, these sounds can be detected by carefully monitoring the power rails. During PC board development, it is a good idea to experiment with different capacitor values ​​by leaving more space on the board in order to be able to adjust the output circuit.

Tips and Tricks for Choosing and Using Audio Codecs

Audio codecs can greatly simplify embedded software and provide applications with good sound quality. Audio codecs can be tricky if the developer has not used them before. To successfully utilize audio codecs, R&D teams should keep in mind the following “tips and tricks”:

Use the Direct Memory Access Controller (DMA) function within the microcontroller to feed the audio codec with minimal CPU intervention. This will help ensure the codec has enough data to process.

When not playing audio, use the codec mute feature to prevent low-level output noise from entering the speakers.

When disabling or enabling playback, use the audio codec’s soft-mute feature to prevent speaker pops and other unwanted noise.

After the codec is initialized, use the terminal application to output the codec registers. This is especially useful when trying to debug problems or adjust speaker output circuits and cabinets.

Take advantage of the internal digital filtering mechanism in the codec. With digital filters, developers can achieve a balanced output that filters out unwanted high and low frequency signals to maximize sound system sound quality.

Don’t forget that tuning is only a useful job when the board and speakers are installed inside the cabinet, as cabinets and installations can make a huge difference.

To get started, developers can experiment with Maxim Integrated’s MAX9867EVKIT+ evaluation kit (Figure 5).

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

The kit consists of a circuit board and associated software configured to send and receive audio data using the Sony/Philips Digital Interface (S/PDIF), but can also be set up to use I2S. The kit has two RCA input jacks, two 3.5 millimeter (mm) analog output headphone jacks, and optical receive and transmit modules. Compatible with Windows, the software, when connected to a PC via a USB cable, opens a graphical user interface (GUI) where developers can experiment with MAX9867 settings (Figure 6).

How do I select and use an audio codec and microcontroller for embedded audio feedback files?

in conclusion

Embedded system users are so accustomed to high-quality audio that they are now reluctant to use buzzers and beeps in place of alarms, alerts, and other user audio feedback. This makes it the responsibility of the development team to implement MP3 playback in their system. At first glance this is a complicated job. However, by using the right audio codec alongside the microcontroller and following some design best practices, developers can balance the cost and complexity associated with audio applications.

The Links:   QM150DY-2HBK LM64183PR LCD-PANEL