STM32F1 CMSIS

Started by tha, July 01, 2021, 08:32:39 AM

Previous topic - Next topic

tha

http://www.disca.upv.es/aperles/arm_cortex_m3/curset/CMSIS/Documentation/DSP/html/index.html

CMSIS DSP Software Library

Introduction

user manual นี้อธิบาย the CMSIS DSP software library, ซึ่งเป็นชุดของ common signal processing functions สำหรับใช้กับ Cortex-M processor based devices.

The library ถูกแบ่งออกเป็นจำนวนหนึ่งของ functions ซึ่งแต่ละครอบคลุมหมวดหมู่เฉพาะ :

   •   Basic math functions
   •   Fast math functions
   •   Complex math functions
   •   Filters
   •   Matrix functions
   •   Transforms
   •   Motor control functions
   •   Statistical functions
   •   Support functions
   •   Interpolation functions

The library มีฟั่งชั่นที่แยกกันสำหรับการทำงานบน 8-bit integers, 16-bit integers, 32-bit integer and 32-bit floating-point values.

tha

Pre-processor Macros

แต่ละ library project มี pre-processor macros ที่แตกต่างกัน.

   •   UNALIGNED_SUPPORT_DISABLE:
Define มาโคร UNALIGNED_SUPPORT_DISABLE, ถ้า the silicon ไม่ได้รองรับ unaligned memory access

   •   ARM_MATH_BIG_ENDIAN:
Define มาโคร ARM_MATH_BIG_ENDIAN เพื่อสร้าง the library สำหรับ big endian targets. โดยค่าเริ่มต้น library สร้างสำหรับ little endian targets.

   •   ARM_MATH_MATRIX_CHECK:
Define มาโคร ARM_MATH_MATRIX_CHECK สำหรับการเช็คบน the input and output sizes ของ matrices

   •   ARM_MATH_ROUNDING:
Define มาโคร ARM_MATH_ROUNDING สำหรับการปัดเศษบนฟังชั่นที่สนับสนุน

   •   ARM_MATH_CMx:
Define มาโคร ARM_MATH_CM4 สำหรับการสร้าง the library บน Cortex-M4 target, ARM_MATH_CM3 สำหรับการสร้าง the library บน Cortex-M3 target and ARM_MATH_CM0 สำหรับการสร้าง the library บน cortex-M0 target.

   •   __FPU_PRESENT:
เริ่มต้นมาโคร __FPU_PRESENT = 1 เมื่อสร้างบน FPU supported Targets. เปิดการใช้งานมาโครนี้สำหรับ M4bf and M4lf libraries

tha

Toolchain Support

The library ถูกพัฒนาและทดสอบด้วย MDK-ARM version 4.23. The library กำลังถูกทดสอบใน GCC and IAR toolchains และอัปเดตบนการกระทำนี้จะถูกทำให้มีใช้ประโยชน์ได้โดยเร็ว.

Using the Library

The library installer บรรจุ prebuilt versions ของ the libraries ใน the Lib folder.

•   arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
•   arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
•   arm_cortexM4l_math.lib (Little endian on Cortex-M4)
•   arm_cortexM4b_math.lib (Big endian on Cortex-M4)
•   arm_cortexM3l_math.lib (Little endian on Cortex-M3)
•   arm_cortexM3b_math.lib (Big endian on Cortex-M3)
•   arm_cortexM0l_math.lib (Little endian on Cortex-M0)
•   arm_cortexM0b_math.lib (Big endian on Cortex-M3)

The library functions ถูกประกาศใน the public file arm_math.h ซึ่งถูกวางใน the Include folder. ง่ายต่อการรวมไฟล์นี้และเชื่อมโยง the appropriate library ใน the application และเริ่มการเรียก the library functions. The Library รองรับ single public header file arm_math.h สำหรับ Cortex-M4/M3/M0 ด้วย little endian และ big endian. header file เดียวกันนี้จะถูกใช้สำหรับ floating point unit(FPU) variants. Define(กำหนด) the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or ARM_MATH_CM0 ขึ้นอยู่กับ the target processor ใน the application.

Examples

The library ส่งออกพร้อมด้วยตัวอย่างจำนวนหนึ่งซึ่งแสดงวิธีใช้ the library functions.

Building the Library

The library installer บรรจุ project files เพื่อสร้างใหม่ libraries บน MDK Tool chain ใน the CMSIS\DSP_Lib\Source\ARM folder.

•   arm_cortexM0b_math.uvproj
•   arm_cortexM0l_math.uvproj
•   arm_cortexM3b_math.uvproj
•   arm_cortexM3l_math.uvproj
•   arm_cortexM4b_math.uvproj
•   arm_cortexM4l_math.uvproj
•   arm_cortexM4bf_math.uvproj
•   arm_cortexM4lf_math.uvproj

The project สามารถถูกสร้างโดยการเปิด the appropriate project ใน MDK-ARM 4.23 chain และกำหนด the optional pre processor MACROs ตามรายละเอียดข้างบน.


tha

http://www.disca.upv.es/aperles/arm_cortex_m3/curset/CMSIS/Documentation/DSP/html/group___radix2___c_f_f_t___c_i_f_f_t.html

Radix-2 Complex FFT Functions

Description

Complex Fast Fourier Transform(CFFT) และ Complex Inverse Fast Fourier Transform(CIFFT) เป็น an efficient algorithm เพื่อคำนวณ Discrete Fourier Transform(DFT) และ Inverse Discrete Fourier Transform(IDFT). ความซับซ้อนในการคำนวณของ CFFT ลดลงอย่างมากเมื่อเทียบกับ DFT.

ชุดของ functions นี้จัดให้มีใช้ CFFT/CIFFT สำหรับ Q15, Q31, และ floating-point data types. The functions ทำงานบนบัฟเฟอร์แบบแทนที่ซึ่งใช้บัฟเฟอร์เดียวกันสำหรับอินพุตและเอาต์พุต. Complex input ถูกเก็บใน input buffer ใน an interleaved fashion.

The functions ทำงานบน blocks of input and output data และแต่ละจะเรียกไปยัง the function ประมวลผล 2*fftLen samples ผ่าน the transform. pSrc ชี้ไปยัง In-place arrays ที่บรรจุ 2*fftLen values.

The pSrc ชี้ไปยัง the array of in-place buffer ขนาด 2*fftLen และ inputs and outputs ถูกเก็บใน an interleaved fashion(รูปแบบที่แทรกกัน) ดังแสดงข้างล่าง.

{real[0], imag[0], real[1], imag[1],..}

ความยาวที่รองรับโดย the transform:

ภายใน, the function ใช้ a radix-2 decimation ใน frequency(DIF) algorithm และขนาดของ the FFT ที่รองรับจะมีความยาวเป็น [16, 32, 64, 128, 256, 512, 1024, 2048, 4096].

ปล. ยังจำกันได้ไหมหล่ะ เลข complex number ที่มีค่า real กับ imagin (2+j3) ที่แปลงไปเป็นขนาดกับมุม เรียกว่าอะไรนะลืมแล้ว ยังจำกันได้อยู่มั๊ย ผมก็ชักจะลืมแล้ว

tha

Algorithm:

Complex Fast Fourier Transform:

     Input real และ imaginary data:
   
      x(n) = xa + j * ya   
      x(n+N/2 ) = xb + j * yb   

     โดยที่ N เป็นความยาวของ FFT
     Output real and imaginary data:
   
      X(2r) = xa'+ j * ya'   
      X(2r+1) = xb'+ j * yb'   

     Twiddle factors สำหรับ radix-2 FFT:
   
      Wn = cosVal + j * (- sinVal)   

Output จาก Radix-2 CFFT ให้ผลใน Digit reversal order. การแลกเปลี่ยนกลาง two branches ของทุก butterfly ให้ผลใน Bit reversed output.

     Butterfly CFFT equations:
   
      xa' = xa + xb 
      ya' = ya + yb 
      xb' = (xa-xb)* cosVal + (ya-yb) * sinVal   
      yb' = (ya-yb)* cosVal - (xa-xb) * sinVal   

Complex Inverse Fast Fourier Transform:

CIFFT ใช้ twiddle factor table เดียวกันกับ CFFT ที่มีการแก้ไขใจthe design equation ดังแสดงข้างล่าง.

     Modified Butterfly CIFFT equations:
   
      xa' = xa + xb 
      ya' = ya + yb 
      xb' = (xa-xb)* cosVal - (ya-yb) * sinVal   
      yb' = (ya-yb)* cosVal + (xa-xb) * sinVal   

tha

ฟังชั่นที่เอาแสดงไม่เหมือนกับกับที่ดาวน์โหลดมาจาก ST ครับ
https://www.st.com/en/embedded-software/stm32cubef1.html
ทำยังไงดีฟังชั่นมันไม่เหมือนกัน version ใหม่ version เก่า
เดี๋ยวค่อยเปิด docs ในโฟลเดอร์ของ ST ดูเอานะ เดี๋ยวผมแปลแล้วจะเอาลิ้งค์ไว้ให้ดูตาม