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

📄 demod.c

📁 信号fm调制与解调的dsp实现
💻 C
字号:
/*****************************************************************************/
/* sine.c                                                                    */
/*                                                                           */
/*****************************************************************************/
#include <type.h>
#include <board.h>
#include <codec.h>
#include <mcbsp54.h>
#include <math.h>
#include <dsplib.h>
/*#include <firlab.h>*/
/*#include <demod.h>*/
/*****************************************************************************/
/* Function Prototypes                                                       */
/*****************************************************************************/

/* This delay routine does not conflict with DSP/BIOS.  It is used in this  */
/* example rather than brd_delay_msec which causes DSP/BIOS conflicts just  */
/* because of this.  If you are not using DSP/BIOS, you can change the code */
/* to use brd_delay_msec.                                                   */
#pragma DATA_SECTION(lpfh,".coeffs")
#pragma DATA_SECTION(dbI,".dbuffer")
#pragma DATA_SECTION(dbQ,".dbuffer")
void Amdemodulate(s16 *inbuf,s16 *outbuf,s16 lengh);
void Ammodulate(s16 *inbuf,s16 *outbuf, s16 lengh);
/*****************************************************************************/
/* Global Variables                                                          */
/*****************************************************************************/
s16 LENGH;
s16 inbuf[1024];
s16 outbuf[1024];
s16 carcos[1024];
s16 carsin[1024];
DATA lpfh[82]={
       -1,     -1,     -1,     -1,     -1,      1,      4,      8,     14,
       21,     29,     36,     42,     44,     41,     31,     13,    -15,
      -52,    -97,   -148,   -200,   -249,   -288,   -310,   -306,   -270,
     -195,    -76,     88,    296,    545,    827,   1132,   1447,   1757,
     2046,   2300,   2505,   2648,   2721,   2721,   2648,   2505,   2300,
     2046,   1757,   1447,   1132,    827,    545,    296,     88,    -76,
     -195,   -270,   -306,   -310,   -288,   -249,   -200,   -148,    -97,
      -52,    -15,     13,     31,     41,     44,     42,     36,     29,
       21,     14,      8,      4,      1,     -1,     -1,     -1,     -1,
       -1
};

 DATA inbufI[1024];
 DATA inbufQ[1024];
 DATA Ilpfout[1024];
 DATA Qlpfout[1024];
 DATA dbI[82];
 DATA dbQ[82];
 DATA *delayptr1I=&dbI[0];
 DATA *delayptr1Q=&dbQ[0];
s16 deoutbuf[1024];
//**********************************************************************
//       SINE LOOKUP TABLE
//**********************************************************************


/*****************************************************************************/
/* MAIN                                                                      */
/*****************************************************************************/

void main()
{
   
    
        
    LENGH=1024;
	Ammodulate(inbuf, outbuf, LENGH);
	Amdemodulate(outbuf,deoutbuf,LENGH);
	

}
 void Ammodulate(s16 *inbuf,s16 *outbuf, s16 lengh)
 {  
    s16 i;
    f32 finbuf;
    f32 foutbuf;
    f32 temp;
    for(i=0;i<lengh;i++)
    {
     finbuf=((float)inbuf[i])/32768.0;  
       temp=1+finbuf;
     foutbuf=temp*(((float)carcos[i])/32768.0);
     outbuf[i]=(s16)(foutbuf*16384.0); 
    }
 }
void Amdemodulate(s16 *inbufp,s16 *outbufp,s16 lengh)
{   
    s16 i;
      
    f32 loutbuf;
    for (i=0;i<lengh;i++)
    {
      inbufI[i]=(((((float)inbufp[i])/32768.0)*(((float)carcos[i])/32768.0))*32768);
      inbufQ[i]=(((((float)inbufp[i])/32768.0)*(((float)carsin[i])/32768.0))*32768); 
    }
    
    
  
    
    fir(inbufI,lpfh,Ilpfout,&delayptr1I,82,1024);
    fir(inbufQ,lpfh,Qlpfout,&delayptr1Q,82,1024);
    for (i=0;i<lengh;i++)
    {
      loutbuf=(float)(Ilpfout[i]/32768.0)*(float)(Ilpfout[i]/32768.0)+(float)(Qlpfout[i]/32768.0)*(float)(Qlpfout[i]/32768.0);
      outbufp[i]=(s16)((sqrt(loutbuf)-0.25)*32768);
    }
    
    
}


⌨️ 快捷键说明

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