请问如何对AIC23采集的声音然后保存到MCBSP寄存器以后的数据取出来用FIR滤波器处理

[复制链接]
 楼主| ian12345x 发表于 2018-9-17 10:44 | 显示全部楼层 |阅读模式
如题,使用的是研旭28335的例程,如何对采集的数据进行处理?是直接使用数组吗,以及是在中断函数处理还是主函数。附上aic23语音采集例程
  1. #include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
  2. #include "DSP2833x_Examples.h"   // DSP2833x Examples Include File



  3. Uint16        volume,tAicRegs;
  4. int ADbuf[500];
  5. int DA_wptr,DA_rptr,y;
  6. Uint16 play_mode=1;                       //采集输出模式

  7. void main(void)
  8. {
  9.         Uint16        temp,i;

  10. // Step 1. Initialize System Control:
  11. // PLL, WatchDog, enable Peripheral Clocks
  12. // This example function is found in the DSP2833x_SysCtrl.c file.
  13.            InitSysCtrl();

  14. // Step 2. Initalize GPIO:
  15. // This example function is found in the DSP2833x_Gpio.c file and
  16. // illustrates how to set the GPIO to it's default state.
  17. // InitGpio();  // Skipped for this example
  18. // For this example, only enable the GPIO for McBSP-A
  19.         InitXintf16Gpio();
  20.            InitMcbspaGpio();

  21.         EALLOW;                                                                  //对aicIO口进行初始化
  22.      GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; //aic_dat         
  23.          GpioCtrlRegs.GPADIR.bit.GPIO12 = 1;
  24.          GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0;
  25.      GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0; //aic_CS         
  26.          GpioCtrlRegs.GPADIR.bit.GPIO13 = 1;
  27.          GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0;
  28.          GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 0; //aic_clk         
  29.          GpioCtrlRegs.GPBDIR.bit.GPIO61 = 1;
  30.          GpioCtrlRegs.GPBPUD.bit.GPIO61 = 0;
  31.          EDIS;

  32. // Step 3. Clear all interrupts and initialize PIE vector table:
  33. // Disable CPU interrupts
  34.            DINT;                                                                 //INT置1,关中断,并初始化PIE矢量表;禁用CPU中断

  35. // Initialize PIE control registers to their default state.
  36. // The default state is all PIE interrupts disabled and flags
  37. // are cleared.
  38. // This function is found in the DSP2833x_PieCtrl.c file.
  39.            InitPieCtrl();                                                 //初始化中断寄存器

  40. // Disable CPU interrupts and clear all CPU interrupt flags:
  41.            IER = 0x0000;
  42.            IFR = 0x0000;                                                //禁用CPU中断并清除所有CPU中断标志

  43. // Initialize the PIE vector table with pointers to the shell Interrupt
  44. // Service Routines (ISR).
  45. // This will populate the entire table, even if the interrupt
  46. // is not used in this example.  This is useful for debug purposes.
  47. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  48. // This function is found in DSP2833x_PieVect.c.
  49.            InitPieVectTable();                                        //初始化中断矢量表

  50. // Step 4. Initialize all the Device Peripherals:
  51. // This function is found in DSP2833x_InitPeripherals.c
  52. // InitPeripherals();     // Not required for this example
  53.            InitMcbspa();          // Initalize the Mcbsp-A in loopback test mode,初始化MCBSP-A模块

  54. //        tAicRegs = 0xFF;
  55. //        SysReg = tAicRegs;

  56.         InitAic23();                //初始化AIC23,
  57.         delay(500);                        //延时500ms?并不是,大约为34ms;
  58.     volume=108;                        //设置播放的音量
  59.   WriteAic23(L_HEADPHONE_VOLUME,0x0180+volume);   //***********
  60.        
  61.         EALLOW;        // This is needed to write to EALLOW protected registers
  62.         PieVectTable.MRINTA = &ISRMcbspSend;                //中断子程序
  63.         EDIS;   // This is needed to disable write to EALLOW protected registers

  64.     PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
  65.     PieCtrlRegs.PIEIER6.bit.INTx5=1;     // Enable PIE Group 6, INT 5
  66.     IER |= M_INT6;                            // Enable CPU INT6,中断使能?

  67.         EINT;   // Enable Global interrupt INTM


  68.         while(1)
  69.         {
  70.             for(temp=30000;temp>0;temp-=100)
  71.                 {
  72.                       for(i=0;i<2;i++)
  73.                       {
  74.                          y=5000;      
  75.                          delay(temp);
  76.                  //        McbspaRegs.DXR1.all = y;
  77.                          y=-5000;      
  78.                          delay(temp);//这什么意思**********
  79.                      //McbspaRegs.DXR1.all = y;
  80.                       }
  81.                 }
  82.         }

  83. }
  84. interrupt void  ISRMcbspSend(void)
  85. {
  86.       int temp;

  87.           PieCtrlRegs.PIEACK.all = PIEACK_GROUP6;
  88.       temp=McbspaRegs.DRR1.all;
  89.         
  90.       DA_rptr++;
  91.       if(DA_rptr>=500)
  92.             DA_rptr=0;

  93.       ADbuf[DA_rptr]=temp;   //保存录音数据
  94.      
  95.       if(play_mode==0)
  96.         McbspaRegs.DXR1.all = y;
  97.                    //警报声的幅值
  98.       else
  99.         McbspaRegs.DXR1.all = temp;        //放音

  100. }
zhangmangui 发表于 2018-9-17 22:04 | 显示全部楼层
你这个工程是播放保存好的录音的     你找找还有一个采集的呢  
 楼主| ian12345x 发表于 2018-9-20 09:20 | 显示全部楼层
zhangmangui 发表于 2018-9-17 22:04
你这个工程是播放保存好的录音的     你找找还有一个采集的呢

这个工程只有这个c文件有main函数哦,把play_mode改成1就实现了录放音的功能。没找到其他工程呀

评论

我跟你的程序一样,为什么我的录放功能不行呢?  发表于 2018-11-7 17:31
我跟你的程序一样,为什么我的录放功能不行呢?  发表于 2018-11-7 17:30
 楼主| ian12345x 发表于 2018-9-20 15:46 | 显示全部楼层
zhangmangui 发表于 2018-9-17 22:04
你这个工程是播放保存好的录音的     你找找还有一个采集的呢

前辈你的意思是中断里的代码是模式0(播放警报声)的代码?那语音采放是直接驱动aic23就自动进行是吗。那哪一段是呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

8

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部

2

主题

8

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部