新手学习CCS V5.4,在ccs里面调试信号调制解调程序
下面的这个程序是从网上找的:
调幅: 程序1: /*头文件定义*/ #include <type.h> #include <board.h> #include <codec.h> #include <mcbsp54.h> #include <tms320.h> #include <dsplib.h> #include <math.h> /*延迟子程序定义*/ void delay(s16 period);
#pragma DATA_SECTION(delaybuff,"delay");
short delaybuff[16]={0};
short *delayptr = &(delaybuff[0]);
short inp_buffer[1]; short out_buffer[1];
short *inp_ptr=inp_buffer; short *out_ptr=out_buffer;
HANDLE hHandset; s16 data; s16 temp_buffer[256]; /*利用查表法产生载波信号定义*/
s16 SINE_TABLE[]= { 0x00324,0x00647 ,0x0096A,0x00C8B ,0x00FAB,0x012C7 ,0x015E1,0x018F8 ,0x01C0B,0x01F19 ,0x02223,0x02527 ,0x02826,0x02B1E ,0x02E10,0x030FB ,0x033DE,0x036B9 ,0x0398C,0x03C56 ,0x03F16,0x041CD ,0x0447A,0x0471C ,0x049B3,0x04C3F ,0x04EBF,0x05133 ,0x0539A,0x055F4 ,0x05842,0x05A81 ,0x05CB3,0x05ED6 ,0x060EB,0x062F1 ,0x064E7,0x066CE ,0x068A5,0x06A6C ,0x06C23,0x06DC9 ,0x06F5E,0x070E1 ,0x07254,0x073B5 ,0x07503,0x07640 ,0x0776B,0x07883 ,0x07989,0x07A7C ,0x07B5C,0x07C29 ,0x07CE2,0x07D89 ,0x07E1C,0x07E9C ,0x07F08,0x07F61 ,0x07FA6,0x07FD7 ,0x07FF5,0x07FFE ,0x07FF5,0x07FD7 ,0x07FA6,0x07F61 ,0x07F08,0x07E9C ,0x07E1C,0x07D89 ,0x07CE2,0x07C29 ,0x07B5C,0x07A7C ,0x07989,0x07883 ,0x0776B,0x07640 ,0x07503,0x073B5 ,0x07254,0x070E1 ,0x06F5E,0x06DC9 ,0x06C23,0x06A6C ,0x068A5,0x066CE ,0x064E7,0x062F1 ,0x060EB,0x05ED6 ,0x05CB3,0x05A81 ,0x05842,0x055F5 ,0x0539A,0x05133 ,0x04EBF,0x04C3F ,0x049B3,0x0471C ,0x0447A,0x041CD ,0x03F16,0x03C56 ,0x0398C,0x036B9 ,0x033DE,0x030FB ,0x02E10,0x02B1E ,0x02826,0x02527 ,0x02223,0x01F19 ,0x01C0B,0x018F8 ,0x015E1,0x012C7 ,0x00FAB,0x00C8B ,0x0096A,0x00647 ,0x00324,0x00000 ,0x0FCDC,0x0F9B9 ,0x0F696,0x0F375 ,0x0F056,0x0ED39 ,0x0EA1F,0x0E708 ,0x0E3F5,0x0E0E7 ,0x0DDDD,0x0DAD9 ,0x0D7DA,0x0D4E2 ,0x0D1F0,0x0CF05 ,0x0CC22,0x0C947 ,0x0C674,0x0C3AA ,0x0C0EA,0x0BE33 ,0x0BB86,0x0B8E4 ,0x0B64D,0x0B3C1 ,0x0B141,0x0AECD ,0x0AC66,0x0AA0C ,0x0A7BE,0x0A57F ,0x0A34D,0x0A12A ,0x09F15,0x09D0F ,0x09B19,0x09932 ,0x0975B,0x09594 ,0x093DD,0x09237 ,0x090A2,0x08F1F ,0x08DAC,0x08C4C ,0x08AFD,0x089C0 ,0x08895,0x0877D ,0x08677,0x08584 ,0x084A4,0x083D8 ,0x0831E,0x08277 ,0x081E4,0x08164 ,0x080F8,0x0809F ,0x0805A,0x08029 ,0x0800B,0x08002 ,0x0800B,0x08029 ,0x0805A,0x0809F ,0x080F8,0x08164 ,0x081E4,0x08277 ,0x0831E,0x083D7 ,0x084A4,0x08584 ,0x08677,0x0877D ,0x08895,0x089C0 ,0x08AFD,0x08C4B ,0x08DAC,0x08F1F ,0x090A2,0x09237 ,0x093DD,0x09594 ,0x0975B,0x09932 ,0x09B19,0x09D0F ,0x09F15,0x0A12A ,0x0A34D,0x0A57F ,0x0A7BE,0x0AA0B ,0x0AC66,0x0AECD ,0x0B141,0x0B3C1 ,0x0B64D,0x0B8E4 ,0x0BB86,0x0BE33 ,0x0C0EA,0x0C3AA ,0x0C674,0x0C947 ,0x0CC22,0x0CF05 ,0x0D1F0,0x0D4E1 ,0x0D7DA,0x0DAD9 ,0x0DDDD,0x0E0E7 ,0x0E3F5,0x0E708 ,0x0EA1E,0x0ED38 ,0x0F055,0x0F375 ,0x0F696,0x0F9B9 ,0x0FCDC,0x00000 };
/*主程序*/
void main() { s16 cnt=2; int i=0,j=0; s32 dat32; /*初始化5402DSK扳*/ if (brd_init(100)) return; /*闪灯程序定义*/ while ( cnt-- ) { brd_led_toggle(BRD_LED0); /* brd_delay_msec(1000); */ delay(1000); brd_led_toggle(BRD_LED1); /* brd_delay_msec(1000); */ delay(1000); brd_led_toggle(BRD_LED2); /* brd_delay_msec(1000); */ delay(1000); }
hHandset = codec_open(HANDSET_CODEC); /* 获取Codec的句柄 */
/* Set codec parameters */ codec_dac_mode(hHandset, CODEC_DAC_15BIT); /* DAC in 15-bit mode */ codec_adc_mode(hHandset, CODEC_ADC_15BIT); /* ADC in 15-bit mode */ codec_ain_gain(hHandset, CODEC_AIN_6dB); /* 输入信号增益为6dB */ codec_aout_gain(hHandset, CODEC_AOUT_MINUS_6dB); /* 输出信号增益为-6 dB */ codec_sample_rate(hHandset,SR_16000); /* 取样频率为16KHz*/
/* Polling and digital loopback */ while (1) { /* Wait for sample from handset */ while (!MCBSP_RRDY(HANDSET_CODEC)) {}; /*数据处理开始*/ data = *(volatile u16*)DRR1_ADDR(HANDSET_CODEC); i=i+100;//产生一个频率为6250HZ的载波 i=i&0xff;//修正样点指针 temp_buffer[j]=data; j++; j=j&0xff; dat32 =(data+10)* SINE_TABLE; *(volatile u32*)DXR1_ADDR(HANDSET_CODEC) = dat32; }
return; }
/*延迟子程序*/ void delay(s16 period) { int i, j;
for(i=0; i<period; i++) { for(j=0; j<period>>1; j++); } }
在CCS V5.4环境下编译,就跳出来很多错误,比如 这些头文件是CCS里面自带的吗? 怎么解决,求大侠指点!!! |