特别说明:完整45期数字信号处理教程,原创高性能示波器代码全开源地址:链接4 [# n4 j2 o( |3 }0 c) U4 d6 ^
第14章 SupportFunctions的使用(二)
. i8 R3 T# G2 D, J3 o 本期教程主要讲解支持函数中的Q7,Q15和Q31分别向其它类型数据转换。 14.1 定点数Q7转换 14.2 定点数Q15转换 14.3 定点数Q31转换 14.4 总结
: i4 `. `& o b7 S* g1 @+ O14.1 定点数Q7转换14.1.1 arm_q7_to_float公式描述: pDst[n] = (float32_t) pSrc[n] / 128; 0 <= n < blockSize. 函数定义如下: void arm_q7_to_float(q7_t * pSrc, float32_t * pDst, uint32_t blockSize) 参数定义: [in] *pSrc points to the Q7 input vector [out] *pDst points to the floating-point output vector [in] blockSize length of the input vector 3 R) b: n# r( Y- a
14.1.2 arm_q7_to_q31公式描述: pDst[n] = (q31_t) pSrc[n] << 24; 0 <= n < blockSize. 函数定义如下: void arm_q7_to_q31(q7_t * pSrc, q31_t * pDst, uint32_t blockSize) 参数定义: [in] *pSrc points to the Q7 input vector [out] *pDst points to the Q31 output vector [in] blockSize length of the input vector q9 b, V5 @% Z- I
14.1.3 arm_q7_to_q15公式描述: pDst[n] = (q15_t) pSrc[n] << 8; 0 <= n < blockSize. 函数定义如下: void arm_q7_to_q15(q7_t * pSrc, q15_t * pDst, uint32_t blockSize) 参数定义: [in] *pSrc points to the Q7 input vector [out] *pDst points to the Q15 output vector [in] blockSize length of the input vector
1 Y, s, a& _3 w. Q5 P/ Z14.1.4 实例讲解实验目的: 1. 学习SupportFunctions中Q7格式数据的转换 实验内容: 1. 按下按键K1, 串口打印函数DSP_Q7的输出结果 实验现象: 通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下: 程序设计: - /*8 ^0 ^ w3 x/ Y7 a: X
- *********************************************************************************************************
& t! C% r* i, J8 }/ O - * 函 数 名: DSP_Q7' G, e, K6 o& x- m
- * 功能说明: Q7格式数据向其它格式转换
" q8 h4 B/ U, b& S7 N! x - * 形 参:无
8 A+ r5 l2 w0 ?$ S - * 返 回 值: 无
: f0 G, g B. V0 |* ~1 p - *********************************************************************************************************
/ R( ~+ j1 E1 i5 P" P3 A - */
]+ N' h# F) O: k8 ?; Q: q - static void DSP_Q7(void)! e G4 l: f% w; p
- {
8 M H' I1 ~2 R* @5 K6 } - float32_t pDst[10];2 I3 H" I% R6 x9 b( v2 A( t) S0 u
- uint32_t pIndex;
" q5 _2 Y5 i" _+ E _+ c7 S - q31_t pDst1[10];
& |; y/ e) j/ X, _ - q15_t pDst2[10];
/ Q8 o r$ j# j g- V0 Q0 Q& a - q7_t pSrc[10];* Z* U" ?6 ?$ h0 P% S8 I; y
- for(pIndex = 0; pIndex < 10; pIndex++)- m8 {! w: [# m5 ?
- {
1 A! M0 @! h' o - pSrc[pIndex] = rand()%128;
3 X- x3 v6 {4 W+ X2 ^ - printf("pSrc[%d] = %d\r\n", pIndex, pSrc[pIndex]);
3 @# I' h5 n; B1 d+ Q. h - }8 ~/ w/ t1 P& L/ Q: o$ x
- /*****************************************************************/0 M u2 Z- C0 a2 D1 M1 Z
- arm_q7_to_float(pSrc, pDst, 10);( K, K7 P+ |4 v5 [% f H
- for(pIndex = 0; pIndex < 10; pIndex++)
. |# V+ c% I2 [% @4 l' ~ - {
+ I+ Z& }" ]& @1 A) v, t9 ? - printf("arm_q7_to_float: pDst[%d] = %f\r\n", pIndex, pDst[pIndex]);
: _" Z7 f9 k3 _7 G( o - }8 X a) {. T) _0 `! e0 N
-
9 \0 J. T( P5 o/ |1 q' N+ S" @7 x - /*****************************************************************/+ }4 _8 {% f( f I1 e
- arm_q7_to_q31(pSrc, pDst1, 10);* |6 v4 ^$ o0 {: m$ O2 W
- for(pIndex = 0; pIndex < 10; pIndex++)
$ N# V/ y+ Q' x/ W - {" D( ]+ m0 n& V/ W6 `1 \
- printf("arm_q7_to_q31: pDst1[%d] = %d\r\n", pIndex, pDst1[pIndex]);
7 M% Z9 |* `5 a. r - }2 e. G6 p* E) q8 k- D# [0 \6 K
- /*****************************************************************/
( A) j/ |1 y. Z7 c - arm_q7_to_q15(pSrc, pDst2, 10);2 O* b! \4 l; h# _% V+ f. g
- for(pIndex = 0; pIndex < 10; pIndex++)
, ?6 e) @1 k0 _, s% f8 x1 j7 f - {
9 J1 S# l4 M0 R# E5 A' y# @ - printf("arm_q7_to_q15: pDst2[%d] = %d\r\n", pIndex, pDst2[pIndex]);
% ~# k. I: g- [' S; R! a6 D4 @ - }
" v/ r" w0 d2 t/ Z" p" E7 } - /*****************************************************************/) J7 B# ?2 @# j$ g8 A, l
- printf("******************************************************************\r\n");
- F w. N# \+ ^! b+ @+ u - }
复制代码 |
14.2.2 arm_q15_to_q31
14.2.3 arm_q15_to_q7
14.2.4 实例讲解
14.3.2 arm_q31_to_q15
14.3.3 arm_q31_to_q7
14.3.4 实例讲解