⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aic23_loopback.c

📁 该程序实现了扬声器功能
💻 C
字号:
#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#include "aic23cfg.h"
#include "mcbspcfg.h"
#include "myapp.h"
#define SOUNDBUFFERLENGTH 0x0d000
unsigned int uSound[SOUNDBUFFERLENGTH];
unsigned int bEcho=0,uEffect=3000;
unsigned int nSoundNumber;
int nWork,nWork1;
main()
{
   /* 
       Step 1. Initialize System Control:
       PLL, WatchDog, enable Peripheral Clocks
       This example function is found in the scsl\scsl.src\DSP281x_SysCtrl.c file.
   */    
   InitSysCtrl();
   
   /* 
       Step 2. Initialize TLVAIC23
       Master ,44.1K Hz MICIN input  PHONE output,etc.
       This example function is found in the aic23cfg.c file.
   */    
   AIC23_cfg();
   
   /* 
       Step 3. Clear all interrupts and initialize PIE vector table:
       Disable CPU interrupts 
   */    
   DINT;
   
   /*   
       Step 4. Initialize PIE control registers to their default state.
       The default state is all PIE interrupts disabled and flags
       are cleared.  
       This function is found in the scsl\scsl.src\DSP281x_PieCtrl.c file.
   */   
   InitPieCtrl();
   
   /*

       Step 5. Disable CPU interrupts and clear all CPU interrupt flags:
   */    
   IER = 0x0000;
   IFR = 0x0000;
   
   /*
       Step 6. Initialize the PIE vector table with pointers to the shell Interrupt 
       Service Routines (ISR).  
       This will populate the entire table, even if the interrupt
       is not used in this example.  This is useful for debug purposes.
       The shell ISR routines are found in DSP281x_DefaultIsr.c.
       This function is found in bcsl\bcsl.src\DSP281x_PieVect.c.
   */
   InitPieVectTable();
   
   /*  
       Step 7. Step 2. Initialize McBSP
       Slave ,external clkxr fsxr ,etc.
       This example function is found in the mcbspcfg.c file.
   */
   McBSP_cfg();
   /*   
       Step 8. Enable interrupts required for this example
   */
   EINT;   
   
   /*
       Step 9. IDLE loop .the main functions is wait the interrupt.
   */
   for(;;);
}
interrupt void mcbspRxFifoIsr(void)
{
   Uint16 i;
   Uint16 rdata_mcbsp[8];                  // Recieved  chn Data 
   for(i=0; i<8; i++)
   {   
       if ( bEcho )				// 是否回放录制下的声音
        {rdata_mcbsp[i]=McbspaRegs.DRR1.all;
         McbspaRegs.DXR1.all=uSound[nSoundNumber];   
         McbspaRegs.DXR2.all=uSound[nSoundNumber];
         nSoundNumber++;
         if ( nSoundNumber>=SOUNDBUFFERLENGTH )
		  {		
			nSoundNumber=0;			
		  }
        }
       
       
       if(bEcho==0)//开始录制声音
        { rdata_mcbsp[i]=McbspaRegs.DRR1.all;
          uSound[nSoundNumber]=rdata_mcbsp[i];
          McbspaRegs.DXR1.all=uSound[nSoundNumber];   
          McbspaRegs.DXR2.all=uSound[nSoundNumber];
          nSoundNumber++;
        
          if ( nSoundNumber>=SOUNDBUFFERLENGTH )
		  {		
			nSoundNumber=0;			
		  }
		}
   }
   McbspaRegs.MFFRX.bit.RXFFOVF_CLEAR=1;   // Clear Overflow flag
   McbspaRegs.MFFRX.bit.RXFFINT_CLEAR=1;   // Clear Interrupt flag
   PieCtrlRegs.PIEACK.all|=0x20;           // Issue PIE ack
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -