你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【安富莱——DSP教程】第14章 SupportFunctions的使用(二)

[复制链接]
baiyongbin2009 发布时间:2015-3-25 11:08
特别说明:完整45期数字信号处理教程,原创高性能示波器代码全开源地址:链接
第14章 SupportFunctions的使用(二)

    本期教程主要讲解支持函数中的Q7,Q15和Q31分别向其它类型数据转换。
    14.1 定点数Q7转换
    14.2 定点数Q15转换
    14.3 定点数Q31转换
    14.4 总结

14.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   

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   

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   

14.1.4 实例讲解
实验目的:
    1. 学习SupportFunctions中Q7格式数据的转换
实验内容:
    1. 按下按键K1, 串口打印函数DSP_Q7的输出结果
实验现象:
    通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:
14.1.png
程序设计:
  1. /*
  2. *********************************************************************************************************
  3. *        函 数 名: DSP_Q7
  4. *        功能说明: Q7格式数据向其它格式转换
  5. *        形    参:无
  6. *        返 回 值: 无
  7. *********************************************************************************************************
  8. */
  9. static void DSP_Q7(void)
  10. {
  11. float32_t pDst[10];
  12. uint32_t pIndex;
  13. q31_t pDst1[10];
  14. q15_t pDst2[10];
  15. q7_t  pSrc[10];
  16. for(pIndex = 0; pIndex < 10; pIndex++)
  17. {
  18. pSrc[pIndex] = rand()%128;
  19. printf("pSrc[%d] = %d\r\n", pIndex, pSrc[pIndex]);
  20. }
  21. /*****************************************************************/
  22. arm_q7_to_float(pSrc, pDst, 10);
  23. for(pIndex = 0; pIndex < 10; pIndex++)
  24. {
  25. printf("arm_q7_to_float: pDst[%d] = %f\r\n", pIndex, pDst[pIndex]);
  26. }

  27. /*****************************************************************/
  28. arm_q7_to_q31(pSrc, pDst1, 10);
  29. for(pIndex = 0; pIndex < 10; pIndex++)
  30. {
  31. printf("arm_q7_to_q31: pDst1[%d] = %d\r\n", pIndex, pDst1[pIndex]);
  32. }
  33. /*****************************************************************/
  34. arm_q7_to_q15(pSrc, pDst2, 10);
  35. for(pIndex = 0; pIndex < 10; pIndex++)
  36. {
  37. printf("arm_q7_to_q15: pDst2[%d] = %d\r\n", pIndex, pDst2[pIndex]);
  38. }
  39. /*****************************************************************/
  40. printf("******************************************************************\r\n");
  41. }
复制代码
收藏 评论3 发布时间:2015-3-25 11:08

举报

3个回答
baiyongbin2009 回答时间:2015-3-25 11:09:07
14.2 定点数Q15转换14.2.1 arm_q15_to_float
公式描述:
    pDst[n] = (float32_t) pSrc[n] / 32768;   0 <= n < blockSize.   
函数定义如下:
    void arm_q15_to_float(q15_t * pSrc, float32_t * pDst, uint32_t blockSize)
参数定义:
     [in]    *pSrc     points to the Q15 input vector   
     [out]   *pDst    points to the floating-point output vector   
     [in]     blockSize length of the input vector   

14.2.2 arm_q15_to_q31
公式描述:
    pDst[n] = (q31_t) pSrc[n] << 16;   0 <= n < blockSize.  
函数定义如下:
    void arm_q15_to_q31(q15_t * pSrc, q31_t * pDst, uint32_t blockSize)
参数定义:
    [in]    *pSrc     points to the Q15 input vector   
    [out]   *pDst    points to the Q31 output vector   
    [in]    blockSize  length of the input vector   

14.2.3 arm_q15_to_q7
公式描述:
    pDst[n] = (q7_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 Q15 input vector   
    [out]  *pDst     points to the Q7 output vector   
    [in]    blockSize length of the input vector   

14.2.4 实例讲解
实验目的:
    1. 学习SupportFunctions中Q15格式数据的转换
实验内容:
    1. 按下按键K1, 串口打印函数DSP_Q7的输出结果
实验现象:
    通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:
14.2.png
程序设计:
  1. /*
  2. *********************************************************************************************************
  3. *        函 数 名: DSP_Q15
  4. *        功能说明: Q15格式数据向其它格式转换
  5. *        形 参:无
  6. *        返 回 值: 无
  7. *********************************************************************************************************
  8. */
  9. static void DSP_Q15(void)
  10. {
  11. float32_t pDst[10];
  12. uint32_t pIndex;
  13. q31_t pDst1[10];
  14. q15_t pSrc[10];
  15. q7_t pDst2[10];
  16. for(pIndex = 0; pIndex < 10; pIndex++)
  17. {
  18. pSrc[pIndex] = rand()%32678;
  19. printf("pSrc[%d] = %d\r\n", pIndex, pSrc[pIndex]);
  20. }
  21. /*****************************************************************/
  22. arm_q15_to_float(pSrc, pDst, 10);
  23. for(pIndex = 0; pIndex < 10; pIndex++)
  24. {
  25. printf("arm_q15_to_float: pDst[%d] = %f\r\n", pIndex, pDst[pIndex]);
  26. }

  27. /*****************************************************************/
  28. arm_q15_to_q31(pSrc, pDst1, 10);
  29. for(pIndex = 0; pIndex < 10; pIndex++)
  30. {
  31. printf("arm_q15_to_q31: pDst1[%d] = %d\r\n", pIndex, pDst1[pIndex]);
  32. }
  33. /*****************************************************************/
  34. arm_q15_to_q7(pSrc, pDst2, 10);
  35. for(pIndex = 0; pIndex < 10; pIndex++)
  36. {
  37. printf("arm_q15_to_q7: pDst2[%d] = %d\r\n", pIndex, pDst2[pIndex]);
  38. }
  39. /*****************************************************************/
  40. printf("******************************************************************\r\n");
  41. }
复制代码


baiyongbin2009 回答时间:2015-3-25 11:09:31
14.3 定点数Q31转换14.3.1 arm_q31_to_float
公式描述:
    pDst[n] = (float32_t) pSrc[n] / 2147483648;   0 <= n < blockSize.   
函数定义如下:
    void arm_q31_to_float(q31_t * pSrc, float32_t * pDst, uint32_t blockSize)
参数定义:
     [in]   *pSrc      points to the Q31 input vector   
     [out]  *pDst     points to the floating-point output vector   
     [in]   blockSize  length of the input vector      

14.3.2 arm_q31_to_q15
公式描述:
   pDst[n] = (q15_t) pSrc[n] >> 16;   0 <= n < blockSize.   
函数定义如下:
   void arm_q31_to_q15(q31_t * pSrc, q15_t * pDst, uint32_t blockSize)
参数定义:
    [in]    *pSrc     points to the Q31 input vector   
    [out]   *pDst    points to the Q15 output vector   
    [in]    blockSize  length of the input vector   

14.3.3 arm_q31_to_q7
公式描述:
    pDst[n] = (q7_t) pSrc[n] >> 24;   0 <= n < blockSize.     
函数定义如下:
    void arm_q31_to_q7(q31_t * pSrc, q7_t * pDst, uint32_t blockSize)
参数定义:
    [in]   *pSrc      points to the Q31 input vector   
    [out]  *pDst     points to the Q7 output vector   
    [in]    blockSize length of the input vector   

14.3.4 实例讲解
实验目的:
    1. 学习SupportFunctions中Q31格式数据的转换
实验内容:
    1. 按下按键K1, 串口打印函数DSP_Q31的输出结果
实验现象:
    通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:
14.3.png
程序设计:
  1. /*
  2. *********************************************************************************************************
  3. *        函 数 名: DSP_Q31
  4. *        功能说明: Q31格式数据向其它格式转换
  5. *        形 参:无
  6. *        返 回 值: 无
  7. *********************************************************************************************************
  8. */
  9. static void DSP_Q31(void)
  10. {
  11. float32_t pDst[10];
  12. uint32_t pIndex;
  13. q31_t pSrc[10];
  14. q15_t pDst1[10];
  15. q7_t pDst2[10];
  16. for(pIndex = 0; pIndex < 10; pIndex++)
  17. {
  18. pSrc[pIndex] = rand();
  19. printf("pSrc[%d] = %d\r\n", pIndex, pSrc[pIndex]);
  20. }
  21. /*****************************************************************/
  22. arm_q31_to_float(pSrc, pDst, 10);
  23. for(pIndex = 0; pIndex < 10; pIndex++)
  24. {
  25. printf("arm_q31_to_float: pDst[%d] = %f\r\n", pIndex, pDst[pIndex]);
  26. }

  27. /*****************************************************************/
  28. arm_q31_to_q15(pSrc, pDst1, 10);
  29. for(pIndex = 0; pIndex < 10; pIndex++)
  30. {
  31. printf("arm_q31_to_q15: pDst1[%d] = %d\r\n", pIndex, pDst1[pIndex]);
  32. }
  33. /*****************************************************************/
  34. arm_q31_to_q7(pSrc, pDst2, 10);
  35. for(pIndex = 0; pIndex < 10; pIndex++)
  36. {
  37. printf("arm_q31_to_q7: pDst2[%d] = %d\r\n", pIndex, pDst2[pIndex]);
  38. }
  39. /*****************************************************************/
  40. printf("******************************************************************\r\n");
  41. }
复制代码
14.4 总结
    本期教程就跟大家讲这么多,有兴趣的可以深入研究这些函数源码的实现。

小蚂蚁快溜跑 回答时间:2015-3-25 13:35:15
学习。。。。看不懂

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版