EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Netizens Application of MDU16 (Provide Ideas, for Reference Only)

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 679 -
29.2 Netizens' application of MDU16 (provide ideas, for reference
only)
Netizen 1: "Data normalization is illustrated with the following simple example"
There is a 7-digit decimal precision data: 0.0000123. Due to the limited data bit width, if you need to use the
bit width effectively, you need to shift the previous data to the left. For example, the data after the left shift is
0.123e-4, and the exponent -4 is stored in the Another register that records the number of left shifts is the size of
the record index. The original register data is converted to 0.123. This frees up the bit width on the right side of
the data to ensure the accuracy of subsequent calculations. The above is just a simple explanation of the principle
of normalization in decimal, and the principle of binary is the same. Among them, the conversion between floating
point and fixed point (integer) must use the principle of normalization. If the exponents of the two floating point
numbers are different when adding and subtracting, they also need to be normalized (this process is called pair
order). If the exponents of two floating-point numbers are very different, there will be a problem of large numbers
eating decimals when adding and subtracting. For example: 0.123e+4 - 0.12e-4 = 0.123e+4 - 0.0000000012e+4 =
0.123e+4. The result is the minuend, because the exponents of the two floating-point numbers need to be exactly
the same before the subtraction operation (for the order), you need to shift the floating point number with a small
exponent to make the exponent become +4. However, the data width is limited to 7 decimal places, and the data
to the right of the number 0.0000000012e+4 will be truncated to 0.0000000e +4 = 0.
Netizen 2: "About the MDU function of STC8C, I would like to share a little bit of my own experience. If there
is anything wrong, please criticize and give advice to improve it together."
1. Functions 1 and 2 are efficient for reducing and expanding integer data. First of all, when performing a double-
operand operation, if the lengths of the two numbers are different, they need to be converted to the same length
before the operation is performed. For example, when multiplying a 32-bit integer by an 8-bit integer, it is
necessary to convert the 8-bit to 32-bit. Secondly, the result of AD sampling also needs displacement when
converting to the specified digit precision. Finally, for example, for network communication, it is necessary to
extract certain bits of data for command parsing or data decomposition and synthesis, and displacement is very
important. Since the 8051 only has an instruction to move 1 bit, the multi-bit movement requires additional
loop codes and requires many instruction cycles, so using the MDU will be several times faster than the 51
assembly instruction.
2. Function 3 is necessary for converting integers to floating-point numbers. For full-precision 32-bit integers, it
generally takes more than 100 instruction cycles to implement this function, so the improvement of the MDU
counter-rotation speed is relatively large. Since the output of AD devices and various three-axis acceleration
outputs are generally integers (such as 16-bit), to perform real number operations and trigonometric function
operations, the output of integers must be converted to floating point numbers, and each time This data type
conversion is required to collect data, and the number of conversions is required. For high-speed data
acquisition and applications like drone control, the overall performance improvement with a DMU can be
substantial.
3. Function 6 is the necessary division function for fixed-point real number operations, and function 4 is the
multiplication operation corresponding to 16-bit x 16-bit result of function 6 as a 32-bit result. The most
common application of function 6 is scale conversion in data processing. For example, for the integer
conversion of a 10-bit AD collected with a reference voltage of 5 volts, the 2-bit fixed decimal point of a 3-
digit digital tube is displayed. The formula is: N32=ADN *500/1023. At this time, as long as (1) AND the AD
sample value to MX (DM1MD0), (2) to send 500 to NX (MD5MD4), (3) to execute function 4, the result is
32 bits, (4) to send 1023 to NX ( MD5MD4), (3) Execute function 6, the 16-bit result is in MX, just get it back.
Another common application is to draw dots and lines on a dot matrix screen such as TFT, such as a digital
oscilloscope. These require multiplication and division of coordinate transformation - first multiply to a 32-bit
integer, and then divide by a 16-bit integer to get 16 bits result.
4. The combination of function 4 and function 6 is the hardware basis for implementing discrete convolution. If
the floating-point acceleration hardware is not used, the four arithmetic operations of floating-point numbers
are an order of magnitude slower than that of integers. Therefore, the predecessors invented the method of
using integer variables to implement convolution. First of all, for example, when we commonly convert JPG
image data to RGB image data or vice versa, Fourier transform is required. Since the length of image data is
fixed (8 bits or 16 bits), discrete Fourier transform can be used. To achieve, which basically only uses 8-bit or

Table of Contents

Related product manuals