项目场景:
利用DSP5509a开发板开发语音录入功能,试图从AIC23模块外接MIC IN接受语音,然后经McBSP传给DSP板做滤波处理,然后再由McBSP返回给AIC23,令AIC23模块PHONE OUT播出语音。
问题描述
在CCS6.1.3开发编程过程中,遇到了错误
报错如下:
Compilation failure
subdir_rules.mk:7: recipe for target ‘codec.obj’ failed
“D:/Users/Administrator/workspace_v6_1_3/5509a/Codec/csl_chiphal.h”, line 201: fatal error #35: #error NO CHIP DEFINED
原因分析:
根据编码器报错提示,说明这个编译错误表明在编译过程中遇到了一个致命的错误。错误消息中提到了 csl_chiphal.h 文件的第 201 行,其中似乎包含了 #error NO CHIP DEFINED。这意味着在这个文件中期望定义某个芯片,但是却没有找到。
这可能是由于编译器无法识别或找到正确的芯片定义,导致无法继续编译。解决这个问题的方法通常是确保项目中包含了正确的芯片定义文件,并且配置正确的编译选项以确保编译器能够找到这些定义。
按照上述提示,检查一下项目的配置,确保包含了正确的芯片定义文件,并且检查代码中可能导致未定义芯片的错误。暂未发现代码中有问题。
有提示说,可能需要查看编译器的配置或者项目文件,确保所有需要的文件都正确包含并且路径设置正确。俺也没发现有问题。
所以这个报错不知如何解决,情求广大牛牛大佬们帮助!
程序原码如下:
#include <math.h>
#include <tms320.h>
#include <stdio.h>
#include <csl.h>
#include <csl_i2c.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>
#include <csl_emif.h>
#include <csl_chip.h>
#include <csl_gpio.h>
#include <dsplib.h>
//#include “hamming30fdacoefs.h”
#include “hamming30hipsfdacoefs.h” //30 points hamming window high pass FIR
#include “bandpass101fdacoefs.h” //101 points bandpass FIR, 300Hz-1.5kHz
// #include “eq110fdacoefs.h”
// #include “eq110hifdacoefs.h”
// #define PI 3.14159265358979323846 // PI value
// #define CONV 32767.999999 // Q15-> float conversion value = 2^15- 2^1-15
#define CODEC_ADDR 0x1A // AIC23 I2C address
#define ST1_55 *(int *)0x03
#define ST3_55 *(int )0x04
#define LBDS1 (((unsigned int )0x600400))
#define keyboard (((unsigned int )0x600C00))
#define GPIO_SEL (((unsigned int *)0x400000))
#define hNX 1 // Fir input data length
// #define NH 31
unsigned int uLED[10]={0x0db,0x50,0x6b,0x73,0xf0,0x0b3,0x0bb,0x51,0x0fb,0x0f3};
DATA *aic23data,*voicedata; // voice input & output data pointer
DATA dbptr / = &db[0] */; // lopass fliter buffer
DATA *dbptrhi; // hipass fliter buffer
// void Delay(unsigned int nDelay); // 延时子程序
void aic_init(); // init aic23
unsigned int time=0;
unsigned int temp_key,temp_key1,firflag; // key buffer & fliter select flag
/**********************************************************************************************************/
void delay(Uint32 k) // true delay func
{
while(k–);
}
/***********************************************************************************************************/
void dealkey() // key func
{
temp_key=keyboard; // read key data
temp_key=temp_key & 0x00ff;
if(0xff!=temp_key) // compare
{
temp_key1=temp_key;
delay(150);
temp_key=keyboard;
temp_key=temp_key & 0x00ff;
if(temp_key == temp_key1)
{
//time++;
//keycode[time]=temp_key;
switch(temp_key)
{
case 0x0fb:
{
LBDS1=0x75; // L
// recordflag=1;
firflag = 0; //0: low pass
}
break;
case 0x0f7:
{
LBDS1=0x56;
// replayflag=1;
}
break;
case 0x0ef:
{
LBDS1=0x07; // H
// stopflag=1;
firflag = 1; //1: high pass
}
break;
case 0x0df:
{
LBDS1=0;
// overflag=1;
}
break;
case 0x0bf:
LBDS1=0x0ff-uLED[5]; //LED just for fun
break;
case 0x07f:
LBDS1=0x0ff-uLED[6];
break;
case 0x0fd:
LBDS1=0x0ff-uLED[7];
break;
case 0x0fe:
LBDS1=0x0ff-uLED[8];
break;
default:break;
}
}
}
}
/*********************************************************************************************************/
/****************************************************************************************************************/
/****************************************************************************************************************/
/锁相环的设置/
PLL_Config myConfig = {
0, //IAI: the PLL locks using the same process that was underway
//before the idle mode was entered
1, //IOB: If the PLL indicates a break in the phase lock,
//it switches to its bypass mode and restarts the PLL phase-locking
//sequence
24, //PLL multiply value; multiply 24 times
1 //Divide by 2 PLL divide value; it can be either PLL divide value
//(when PLL is enabled), or Bypass-mode divide value
//(PLL in bypass mode, if PLL multiply value is set to 1)
};
EMIF_Config emiffig = {
0x221, //EGCR : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence
// the WPE = 0 ,forbiden the writing posting when we debug the EMIF
// the MEMCEN = 1,the memory clock is reflected on the CLKMEM pin
// the NOHOLD = 1,HOLD requests are not recognized by the EMIF
0xFFFF, //EMI_RST: any write to this register resets the EMIF state machine
0x3FFF, //CE0_1: CE0 space control register 1
// MTYPE = 011,Synchronous DRAM(SDRAM),16-bit data bus width
0xFFFF, //CE0_2: CE0 space control register 2
0x00FF, //CE0_3: CE0 space control register 3
// TIMEOUT = 0xFF;
0x3FFF, //CE1_1: CE0 space control register 1
0xFFFF, //CE1_2: CE0 space control register 2
0x00FF, //CE1_3: CE0 space control register 3
0x1FFF, //CE2_1: CE0 space control register 1
0xFFFF, //CE2_2: CE0 space control register 2
0x00FF, //CE2_3: CE0 space control register 3
0x1FFF, //CE3_1: CE0 space control register 1
0xFFFF, //CE3_2: CE0 space control register 2
0x00FF, //CE3_3: CE0 space control register 3
0x2911, //SDC1: SDRAM control register 1
// TRC = 8
// SDSIZE = 0;SDWID = 0
// RFEN = 1
// TRCD = 2
// TRP = 2
0x0410, //SDPER : SDRAM period register
// 7ns *4096
0x07FF, //SDINIT: SDRAM initialization register
// any write to this register to init the all CE spaces,
// do it after hardware reset or power up the C55x device
0x0131 //SDC2: SDRAM control register 2
// SDACC = 0;
// TMRD = 01;
// TRAS = 0101;
// TACTV2ACTV = 0001;
};
MCBSP_Config Mcbsptest;
/McBSP set,we use mcbsp1 to send and recieve the data between DSP and AIC23/
MCBSP_Config Mcbsp1Config = {
MCBSP_SPCR1_RMK(
MCBSP_SPCR1_DLB_OFF, /* DLB = 0,禁止自闭环方式 /
MCBSP_SPCR1_RJUST_LZF, / RJUST = 2 /
MCBSP_SPCR1_CLKSTP_DISABLE, / CLKSTP = 0 /
MCBSP_SPCR1_DXENA_ON, / DXENA = 1 /
0, / ABIS = 0 /
MCBSP_SPCR1_RINTM_RRDY, / RINTM = 0 /
0, / RSYNCER = 0 /
MCBSP_SPCR1_RRST_DISABLE / RRST = 0 /
),
MCBSP_SPCR2_RMK(
MCBSP_SPCR2_FREE_NO, / FREE = 0 /
MCBSP_SPCR2_SOFT_NO, / SOFT = 0 /
MCBSP_SPCR2_FRST_FSG, / FRST = 0 /
MCBSP_SPCR2_GRST_CLKG, / GRST = 0 /
MCBSP_SPCR2_XINTM_XRDY, / XINTM = 0 /
0, / XSYNCER = N/A /
MCBSP_SPCR2_XRST_DISABLE / XRST = 0 /
),
/单数据相,接受数据长度为16位,每相2个数据/
MCBSP_RCR1_RMK(
MCBSP_RCR1_RFRLEN1_OF(1), / RFRLEN1 = 1 /
MCBSP_RCR1_RWDLEN1_16BIT / RWDLEN1 = 2 /
),
MCBSP_RCR2_RMK(
MCBSP_RCR2_RPHASE_SINGLE, / RPHASE = 0 /
MCBSP_RCR2_RFRLEN2_OF(0), / RFRLEN2 = 0 /
MCBSP_RCR2_RWDLEN2_8BIT, / RWDLEN2 = 0 /
MCBSP_RCR2_RCOMPAND_MSB, / RCOMPAND = 0 /
MCBSP_RCR2_RFIG_YES, / RFIG = 0 /
MCBSP_RCR2_RDATDLY_1BIT / RDATDLY = 1 /
),
MCBSP_XCR1_RMK(
MCBSP_XCR1_XFRLEN1_OF(1), / XFRLEN1 = 1 /
MCBSP_XCR1_XWDLEN1_16BIT / XWDLEN1 = 2 */
),
MCBSP_XCR2_RMK(
MCBSP_XCR2_XPHASE_SINGLE, /* XPHASE = 0 /
MCBSP_XCR2_XFRLEN2_OF(0), / XFRLEN2 = 0 /
MCBSP_XCR2_XWDLEN2_8BIT, / XWDLEN2 = 0 /
MCBSP_XCR2_XCOMPAND_MSB, / XCOMPAND = 0 /
MCBSP_XCR2_XFIG_YES, / XFIG = 0 /
MCBSP_XCR2_XDATDLY_1BIT / XDATDLY = 1 /
),
MCBSP_SRGR1_DEFAULT,
MCBSP_SRGR2_DEFAULT,
MCBSP_MCR1_DEFAULT,
MCBSP_MCR2_DEFAULT,
MCBSP_PCR_RMK(
MCBSP_PCR_IDLEEN_RESET, / IDLEEN = 0 /
MCBSP_PCR_XIOEN_SP, / XIOEN = 0 /
MCBSP_PCR_RIOEN_SP, / RIOEN = 0 /
MCBSP_PCR_FSXM_EXTERNAL, / FSXM = 0 /
MCBSP_PCR_FSRM_EXTERNAL, / FSRM = 0 /
0, / DXSTAT = N/A /
MCBSP_PCR_CLKXM_INPUT, / CLKXM = 0 /
MCBSP_PCR_CLKRM_INPUT, / CLKRM = 0 /
MCBSP_PCR_SCLKME_NO, / SCLKME = 0 /
MCBSP_PCR_FSXP_ACTIVEHIGH, / FSXP = 0 /
MCBSP_PCR_FSRP_ACTIVEHIGH, / FSRP = 1 /
MCBSP_PCR_CLKXP_FALLING, / CLKXP = 1 /
MCBSP_PCR_CLKRP_RISING / CLKRP = 1 */
),
MCBSP_RCERA_DEFAULT,
MCBSP_RCERB_DEFAULT,
MCBSP_RCERC_DEFAULT,
MCBSP_RCERD_DEFAULT,
MCBSP_RCERE_DEFAULT,
MCBSP_RCERF_DEFAULT,
MCBSP_RCERG_DEFAULT,
MCBSP_RCERH_DEFAULT,
MCBSP_XCERA_DEFAULT,
MCBSP_XCERB_DEFAULT,
MCBSP_XCERC_DEFAULT,
MCBSP_XCERD_DEFAULT,
MCBSP_XCERE_DEFAULT,
MCBSP_XCERF_DEFAULT,
MCBSP_XCERG_DEFAULT,
MCBSP_XCERH_DEFAULT
};
MCBSP_Handle hMcbsp;
/* This next struct shows how to use the I2C API /
/ Create and initialize an I2C initialization structure /
I2C_Setup I2Cinit = {
0, / 7 bit address mode /
0, / own address - don’t care if master /
7, / clkout value (Mhz) /
400, / a number between 10 and 400*/
0, /* number of bits/byte to be received or transmitted (8)/
0, / DLB mode on*/
1 /* FREE mode of operation on*/
};
I2C_Config testI2C; //all config bit zero, it works
// I2C: addr 7bit + data 9bit
/数字音频接口格式设置 // see tlv320a23b datasheet
AIC23为主模式,数据为DSP模式,数据长度16位/
Uint16 digital_audio_inteface_format[2]={0x0e,0x53};
/AIC23的波特率设置,0x23采样率为44.1K,0x0c采样率为8K/
Uint16 sample_rate_control[2] = {0x10,0x0c};
/AIC23寄存器复位/
Uint16 reset[2] ={0x1e,0x00};
/AIC23节电方式设置,所有部分均所与工作状态/
Uint16 power_down_control[2] ={0x0c,0x01};
/AIC23模拟音频的控制
DAC使能,ADC输入选择为MIC/
Uint16 analog_aduio_path_control[2] ={0x08,0x14};
/AIC23数字音频通路的控制/
Uint16 digital_audio_path_control[2] ={0x0a,0x05};
/AIC23数字接口的使能/
Uint16 digital_interface_activation[2] ={0x12,0x01};
/AIC23左通路音频调节/
// Uint16 left_line_input_volume_control[2] ={0x00,0x17};
/AIC23右通路音频调节/
// Uint16 right_line_input_volume_control[2] ={0x02,0x17};
/AIC23耳机左通路音频调节/
Uint16 left_headphone_volume_control[2] ={0x05,0x79};
/AIC23耳机右通路音频调节/
Uint16 right_headphone_volume_control[2] = {0x07,0x79};
/定义McBSP的句柄/
Uint16 i2c_status;
//Uint16 temp;
//Uint16 nin=0,bcount=0;
//long dec_sour,dec_temp;
/以下,主程序开始*********************************************
void main(void)
{
i2c_status = 1; // i2c status
CSL_init(); // init csl
CHIP_RSET(XBSR,0x0a01);
GPIO_RSET(IODIR,0xFF);
/*设置系统的运行速度为144MHz*/
PLL_config(&myConfig);
EMIF_config(&emiffig); //set sdram
dbptr = (short *)0x021000; //point to sdram
dbptrhi = (short *)0x022000;
I2C_RSET(I2CMDR,0);
/*设置预分频寄存器,I2C的mode clock is 12MHz*/
delay(100);
I2C_RSET(I2CSAR,0x001A);
I2C_RSET(I2CMDR,0x0620);
I2C_setup(&I2Cinit);
/*设置I2C的Mater clock*/
I2C_RSET(I2CCLKL,100);
I2C_RSET(I2CCLKH,100);
I2C_getConfig(&testI2C);
/*初始化McBSP1*/
hMcbsp = MCBSP_open(MCBSP_PORT1,MCBSP_OPEN_RESET);
/*设置McBSP0*/
MCBSP_config(hMcbsp,&Mcbsp1Config);
/*启动McBSP0*/
MCBSP_start(hMcbsp,
MCBSP_RCV_START | MCBSP_XMIT_START,
0);
MCBSP_getConfig(hMcbsp,&Mcbsptest);
aic_init(); //写i2c寄存器和aic23寄存器
aic23data = (DATA *)0x023000; //point to sdram
voicedata = (DATA *)0x023100;
while(1)
{
dealkey();
//MCBSP_write16(hMcbsp,aic23data);
while(!MCBSP_rrdy(hMcbsp)){}; // check McBSP read stauts
//if(MCBSP_rrdy(hMcbsp))
*aic23data = (DATA)(MCBSP_read16(hMcbsp) - 63800); // receive mic data
if(firflag) //firflag :0:low pass, 1:high pass
{
fir( // fir from DSP Lib
aic23data,//x, // input data array
Bhi,//h, //
voicedata,//r,
dbptrhi,
hNX,
BhiL//NH
);
}
else
{
fir(
aic23data,//x,
B,//h,
voicedata,//r,
dbptr,
hNX,
BL//NH
);
}
while(!MCBSP_xrdy(hMcbsp)){};
//if(MCBSP_xrdy(hMcbsp))
MCBSP_write16(hMcbsp,(unsigned int)(*voicedata + 63800)); // send voice data
}
}
/至此,主程序结束********************************************\
******************************************************************************/
void aic_init()
{
/reset AIC23/
i2c_status = I2C_write( reset, //pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
delay(1000);
/设置AIC23各部分均工作/
i2c_status = I2C_write( power_down_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置AIC23的数字接口/
i2c_status = I2C_write( digital_audio_inteface_format,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置AIC23模拟通路/
i2c_status = I2C_write( analog_aduio_path_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置数字通路/
i2c_status = I2C_write( digital_audio_path_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置AIC23的采样率/
i2c_status = I2C_write( sample_rate_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置耳机音量/
i2c_status = I2C_write( left_headphone_volume_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
i2c_status = I2C_write( right_headphone_volume_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
/设置Line输入的音量/
/* i2c_status = I2C_write( left_line_input_volume_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
i2c_status = I2C_write( right_line_input_volume_control,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
); */
/启动AIC23/
i2c_status = I2C_write( digital_interface_activation,//pointer to data array
2, //length of data to be transmitted
1, //master or slaver
CODEC_ADDR, //slave address to transmit to
1, //transfer mode of operation
30000 //time out for bus busy
);
}