Abstract: The MAXQ2000, with its integrated multiply-accumulate unit (MAC) and single-cycle core, is well suited for use as a general-purpose microcontroller (µC). The performance and I/O peripherals of the MAXQ2000 make it suitable for a wide variety of applications: alarm clocks, handheld medical devices, digital readers, and other applications that require low power, high performance, and a large number of I/Os. The MAXQ2000, with its integrated MAC, has entered the realm of DSP (µC) applications.
How much performance can the MAXQ2000's MAC achieve? This application note uses an audio filter as an example to explain this question and quantify the performance supported by the MAXQ2000.
Software and Hardware Requirements
This application note demonstrates a simple audio filter. The audio data is a pre-recorded audio recording of the author reading "The
pipe
began to rust while new". This is not randomly selected, but contains the appropriate frequency combination to test the effect of the filter (http://www.cs.columbia.edu/~hgs/audio/harvard.html). The audio recording can be replaced with any suitable length of 8kHz recording, but it is not necessary.
The hardware required for this application note includes the MAXQ2000 evaluation board and a simple circuit to implement the computer speaker interface.
The available MAXQ2000 evaluation board is the best tool to understand the performance of the MAXQ2000. It includes an LCD panel and a set of LEDs. All I/O pins of the MAXQ2000 are accessible through the evaluation board. The MAX1407
ADC
/
DAC
integrated on the evaluation board
can be used for audio output.
The second part of the hardware required can be easily implemented on a circuit breadboard. The circuit used for the demonstration is shown in Figure 1. It connects to the MAXQ2000 EV kit at J7 using a 1 x 8 female header that needs to be connected to any ground potential (TP1 on the MAXQ2000 EV kit can be used). The speaker connector can be of any type, but a 3.5mm stereo jack is shown to facilitate connection to common computer speakers. Note that the two input channels are connected in parallel, as our demonstration uses only one audio channel (mono)
.
Figure
1.
Additional
Hardware
Required
for Audio Playback
...
Run the Demo
The buttons on the MAXQ2000 EV kit are used to select filters and play the filtered audio samples. Use button SW4 to select the filter, and the filter name will be displayed on the LCD (HI for highpass , LO for lowpass, BP for bandpass, ALL for allpass). Use button SW5 to play the audio through the selected filter. The filter can be switched during playback.
Design a simple FIR filter
This article uses a
Java
™ applet to easily generate new filters. Rather than using standard windowing techniques to generate filter parameters, filters are simply "designed" by placing zeros on a pole-zero plot, as shown in Figure 2. The applet places zeros anywhere on the coordinate plane and automatically updates the parameters of the FIR filter required for the demonstration. Note that the demonstration only supports all-zero filters. Supporting IIR filters is not difficult and is explained in detail in the Supporting IIR Filters section.
Figure 2. Using a Pole-Zero Plot to Generate a Simple FIR Filter
The linear equation for a general filter is:
y(n) +
bKy(k) =
aJx(j)
where k is the order of the filter's feedback portion and j is the order of the filter's feedforward portion.
An IIR filter can be simply represented by:
y(n) = 0.5y(n-1) + x(n) - 0.8x(n-1)
Some filters are classified as FIR filters and do not include a feedback portion. In other words, the y component is not included in the filter characteristic equation:
y(n) =
aJx(j)
y(n) = x(n) - 0.2x(n - 1) + 0.035x(n - 3)
In any case, the filter can be reduced to a characteristic equation, which is essentially a weighted average of past inputs and outputs. The filter design is to generate the Aj and Bk values. To efficiently calculate the filter output, you need hardware that can multiply and add signed numbers quickly, which is the MAXQ2000's multiply-accumulate unit.
Implementing a filter using a multiply-accumulate (MAC) unit
The applet in the previous section calculates the filter parameters by specifying the zero coordinates in the graph. However, the calculation results are floating point numbers, while the MAC is a pure 16-bit integer operation. To solve this problem, this demonstration uses a fixed point numerical system, where bits 0 to 15 of the parameter are the value to the right of the decimal point (the 16th bit represents the sign polarity). After the operation is completed, the 48-bit result in the MAC accumulator is shifted to remove the remainder.
This solution is a trade-off between accuracy and speed. In many cases, the error produced by this method is negligible. For diagnostic purposes, the applet can display three curves of the calculated filter. The first curve shows the operation of the ideal filter using 64-bit floating point numbers. This curve is labeled "Ideal Transform" in Figure 2.
Figure 3 plots the remaining curves generated by the applet. The first curve shows the effect of filtering using 16-bit fixed point numbers. In many cases, the error is not obvious. The last curve is an error indicator, showing the ideal frequency response divided by the actual frequency response. Ideally, this is a straight line with Y = 1.
Figure 3. 16-bit filter in action and with rounding errors (visually no errors)
For simplicity, the applet generates the floating-point parameters required by the MAXQ® filter, so new filters can be implemented simply by cutting and pasting them into the filter source file (data.asm file). The applet also generates two other values, the filter order (number of parameters) and the shift amount, so the application can shift the final result appropriately. The data appears in the text box at the bottom of the applet and may be presented in the following ways:
Zeroes: dc16 dc16 12, 11, 0x1000, 0x26d3, 0x1e42, 0xf9a3, 0xecde, 0xff31, 0xa94, 0x2ae, 0xfd0c, 0xff42, 0xde Shift amount: 12
Implementing filters using MAXQ assembly language
To achieve the best performance and to perform accurate performance analysis, the actual filter is implemented in assembly language so that the exact number of cycles required to produce one output can be calculated and the performance of other data settings can be estimated.
The MAX1407 contains a 12-bit
ADC
. Since the input data is 16 bits wide, the filter produces a 16-bit result. Although the 4 least significant bits (LSBs) are not used in this application, the performance can still be analyzed normally for 16-bit calculations and outputs (CD-quality audio is 16 bits).
In this example, the filter parameters are stored in a table in the code area. After a filter is selected, the application finds the appropriate filter, reads the number of shifts and taps, and then prepares to begin digital filtering. The following code applies the filter parameters:
move MCNT, #22h ; signed, mult-accum, clear regs first zeroes_filterloop: move A[0], DP[0] ; let's see if we are out of data cmp #W:rawaudiodata ; compare to the start of the audio data lcall UROM_MOVEDP1INC ; get next filter coefficient move MA, GR ; multiply filter coefficient... lcall UROM_MOVEDP0DEC ; get next filter data move MB, GR ; multiply audio sample... jump e, zeroes_outofdata; stop if at the start of the audio data djnz LC[0], zeroes_filterloop zeroes_outofdata: move A[2], MC2; get MAC result HIGH move A[1], MC1; get MAC result MID move A[0], MC0; get MAC result LOW
Before executing this code, LC[0] is loaded with the number of filter taps, DP[0] is loaded with the current filter input byte address, and DP[1] is loaded with the filter parameter starting address. DP[1] processes the filter parameters in incrementing fashion, and DP[0] processes the input data in decrementing fashion (most recently input data is processed first).
Since the MAC operates in a single cycle, the processing code is relatively small. MCNT is set to 22h to represent the use of signed integers. In the main loop, consecutive writes to MA and then MB trigger the multiply-accumulate operation, with the result ready on the next
clock
cycle. Since the accumulator is 48 bits (the result of the multiplication is 32 bits), there will be no overflow (unless there are 64,000 taps in the filter!).
performance
This application processes mono 16-bit audio data and produces an 8kHz output, which does not fully utilize the microcontroller's capabilities. Since the filter is written in assembly language, an expression can be used to easily calculate the number of cycles required to calculate a FIR filter of length N. This expression can then be used to calculate
the maximum filtering rate
using
the algorithm
listed above.
The functions used to generate audio samples can be divided into three parts: initialization, filter calculation loop, and result correction. In this example, initialization requires 38 cycles, filter calculation requires 17 cycles per filter parameter, and result correction requires 9 + (6 x S) cycles, where S is the number of shifts. Typically, a shift of 12 results in 81 cycles of result correction. Therefore, 119 + (17 x N) cycles are required to produce a filtered output. At 20MHz, the MAXQ2000 can run a 100-tap filter at nearly 11kHz, which is already quite good voice quality.
Now let's go back and re-analyze the application to simplify it further. We will focus on the filter loop because it takes up the most cycles and is the most tedious.
Several key changes can be made to the loop code to improve efficiency. Note that we use audio samples that were prerecorded and stored in the code area. Because the MAXQ uses Harvard architecture, searching the code space takes more time than searching the data space. The functions called UROM_MOVEDP1INC and UROM_MOVEDP0DEC require five cycles each to execute (two cycles for LCALL and three cycles inside the function). If the filter is stored in
RAM
and processes real-time input data stored in RAM, only two cycles each (one cycle to select the pointer and one cycle to read it) are required. If 256 words of RAM are used for the filter, a circular buffer can be implemented using BP[Offs] to store the input data. These changes reduce the loop time from 17 cycles to 11. The filter loop looks like this (the required cycle number is listed first in the comments):
Previous article:Video surveillance adapter circuit
Next article:Quick Start: Driving a 16-Segment LED Display with the MAX6954
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- LSM6DSL calls STM32_MotionGC_Library's .a file and compiles and reports an error
- The wireless charging coil that can run away by itself is here - Mr. He from Bilibili has made a product that Apple has eliminated
- Questions about op amp parameters
- Compile-time solution
- How to explain the ground connection of the reference voltage of the RN8209 Ruineng micro power detection chip to the 220v live wire? ? ? ?
- Xunwei 4412 development board burns QT program to the development board with one click
- Question about capacitors
- Practical RF training course sharing 3
- E2PROM maximum capacity
- A simple "video player" based on 51 single chip microcomputer