UM0585 - STM32F10xxx DSP library.pdf

(187 KB) Pobierz
STM32F10xxx DSP library
UM0585
User manual
STM32F10xxx
DSP library
Introduction
This user manual describes the STM32F10xxx DSP (digital signal processing) library, which
is a suite of common digital signal processing functions:
PID controller
Fast Fourier transform
FIR and IIR filters
The library contains C and assembly functions that have been ported and tested on the IAR
EWARM 5.20, Keil RVMDK 3.23 and Raisonance RIDE7 (GNU compiler) toolchains.
October 2008
Rev 1
1/23
273873261.002.png
Contents
UM0585
Contents
1
DSP Library description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2
PID controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2
DSP library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 DoPID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 DoFullPID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 PID_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
Complex 16-bit radix-4 FFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2
DSP library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.1 cr4_fft_64_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2 cr4_fft_256_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.3 cr4_fft_1024_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3
FFT performance improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4
16-bit FIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2
DSP library function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2.1 fir_16by16_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5
16-bit IIR filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.2
DSP library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.1 iiarma_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2.2 iir_biquad_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6
STM32F10xxx DSP library benchmark . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.1
Function code footprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2
Function execution time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2.1
PID controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2.2
Fast Fourier transform (FFT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.2.3
FIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2/23
273873261.003.png
UM0585
Contents
6.2.4
IIR filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3/23
273873261.004.png
List of tables
UM0585
List of tables
Table 1. STM32F10xxx DSP library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Table 2. DoPID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 3. DoFullPID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 4. PID_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 5. cr4_fft_64_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 6. cr4_fft_256_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 7. cr4_fft_1024_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 8. fir_16by16_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 9. iirarma_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 10. iir_biquad_stm32 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 11. STM32F10xxx DSP library functions code footprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 12. PID controller, error computed outside the routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 13. PID controller, error computed within the routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 14. Complex radix 4, 16-bit FFT, coefficients in Flash memory . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 15. Complex radix 4, 16-bit FFT, coefficients in RAM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 16. 16-bit, 32-tap FIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 17. 16-bit canonic form, 4 biquad IIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 18. 16-bit direct-form I, 8 th -order IIR filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 19. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4/23
273873261.005.png
UM0585
List of figures
List of figures
Figure 1.
Block diagram of PID controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 2.
Block diagram of an FIR filter of length N . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 3.
Block diagram of the direct form I of second-order IIR filter . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 4.
Block diagram of the canonical form of a second-order IIR filter . . . . . . . . . . . . . . . . . . . . 15
5/23
273873261.001.png
Zgłoś jeśli naruszono regulamin