|
特别说明:完整45期数字信号处理教程,原创高性能示波器代码全开源地址:链接
第13章 SupportFunctions的使用(一)
本期教程主要讲解支持函数中的数据拷贝,数据赋值和浮点数转换为定点数。
13.1 数据拷贝 Copy
13.2 数据填充 Fill
13.3 浮点数转定点数 Float to Fix
13.4 总结
13.1 数据拷贝Copy
这部分函数用于数据拷贝,公式描述如下:
pDst[n] = pSrc[n]; 0 <= n < blockSize.
13.1.1 arm_copy_f32
函数定义如下:
void arm_copy_f32(float32_t * pSrc, float32_t * pDst, uint32_t blockSize)
参数定义:
[in] *pSrc points to input vector
[out] *pDst points to output vector
[in] blockSize length of the input vector
13.1.2 arm_copy_q31
此函数的使用比较简单,函数定义如下:
void arm_copy_q31(q31_t * pSrc, q31_t * pDst, uint32_t blockSize)
参数定义:
[in] *pSrc points to input vector
[out] *pDst points to output vector
[in] blockSize length of the input vector
13.1.3 arm_copy_q15
函数定义如下:
void arm_copy_q15(q15_t * pSrc, q15_t * pDst, uint32_t blockSize)
参数定义:
[in] *pSrc points to input vector
[out] *pDst points to output vector
[in] blockSize length of the input vector
13.1.4 arm_copy_q7
函数定义如下:
void arm_copy_q7(q7_t * pSrc, 7_t * pDst, int32_t blockSize)
参数定义:
[in] *pSrc points to input vector
[out] *pDst points to output vector
[in] blockSize length of the input vector
13.1.5 实例讲解
实验目的:
1. 学习SupportFunctions中的数据拷贝
实验内容:
1. 按下按键K1, 串口打印函数DSP_Copy的输出结果
实验现象:
通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:
程序设计:
- /*
- *********************************************************************************************************
- * 函 数 名: DSP_Copy
- * 功能说明: 数据拷贝
- * 形 参:无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- static void DSP_Copy(void)
- {
- float32_t pSrc[10] = {0.6557, 0.0357, 0.8491, 0.9340, 0.6787, 0.7577, 0.7431, 0.3922, 0.6555, 0.1712};
- float32_t pDst[10];
- uint32_t pIndex;
- q31_t pSrc1[10];
- q31_t pDst1[10];
- q15_t pSrc2[10];
- q15_t pDst2[10];
- q7_t pSrc3[10];
- q7_t pDst3[10];
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- printf("pSrc[%d] = %f\r\n", pIndex, pSrc[pIndex]);
- }
- arm_copy_f32(pSrc, pDst, 10);
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- printf("arm_copy_f32: pDst[%d] = %f\r\n", pIndex, pDst[pIndex]);
- }
-
- /*****************************************************************/
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- pSrc1[pIndex] = rand();
- printf("pSrc1[%d] = %d\r\n", pIndex, pSrc1[pIndex]);
- }
- arm_copy_q31(pSrc1, pDst1, 10);
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- printf("arm_copy_q31: pDst1[%d] = %d\r\n", pIndex, pDst1[pIndex]);
- }
- /*****************************************************************/
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- pSrc2[pIndex] = rand()%32768;
- printf("pSrc2[%d] = %d\r\n", pIndex, pSrc2[pIndex]);
- }
- arm_copy_q15(pSrc2, pDst2, 10);
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- printf("arm_copy_q15: pDst2[%d] = %d\r\n", pIndex, pDst2[pIndex]);
- }
- /*****************************************************************/
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- pSrc3[pIndex] = rand()%128;
- printf("pSrc3[%d] = %d\r\n", pIndex, pSrc3[pIndex]);
- }
- arm_copy_q7(pSrc3, pDst3, 10);
- for(pIndex = 0; pIndex < 10; pIndex++)
- {
- printf("arm_copy_q7: pDst3[%d] = %d\r\n", pIndex, pDst3[pIndex]);
- }
- /*****************************************************************/
- printf("******************************************************************\r\n");
- }
复制代码 |
-
|