1. 麦克风输入需要修改的内容,之前的版本是LINE IN的输入。实现功能,检测麦克风的输入,并且同时在耳机里面播放。

#include <csl.h>
#include <csl_i2c.h>
#include <stdio.h>
#include <csl_pll.h>
#include <csl_mcbsp.h> #include "myapp.h"
#include "csedu.h"
#include "scancode.h"
#include <math.h> #define CODEC_ADDR 0x1A /*锁相环的设置*/
PLL_Config myConfig = {
, //IAI: the PLL locks using the same process that was underway
//before the idle mode was entered
, //IOB: If the PLL indicates a break in the phase lock,
//it switches to its bypass mode and restarts the PLL phase-locking
//sequence
, //PLL multiply value; multiply 24 times
//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)
}; //FFT相关的代码
#define PI 3.1415926
#define SAMPLENUMBER 128 void InitForFFT();
void MakeWave(); int INPUT[SAMPLENUMBER],DATA[SAMPLENUMBER];
float fWaveR[SAMPLENUMBER],fWaveI[SAMPLENUMBER],w[SAMPLENUMBER];
float sin_tab[SAMPLENUMBER],cos_tab[SAMPLENUMBER];
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 */
, /* ABIS = 0 */
MCBSP_SPCR1_RINTM_RRDY, /* RINTM = 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 */
, /* XSYNCER = N/A */
MCBSP_SPCR2_XRST_DISABLE /* XRST = 0 */
),
/*单数据相,接受数据长度为16位,每相2个数据*/
MCBSP_RCR1_RMK(
MCBSP_RCR1_RFRLEN1_OF(), /* RFRLEN1 = 1 */
MCBSP_RCR1_RWDLEN1_16BIT /* RWDLEN1 = 2 */
),
MCBSP_RCR2_RMK(
MCBSP_RCR2_RPHASE_SINGLE, /* RPHASE = 0 */
MCBSP_RCR2_RFRLEN2_OF(), /* 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(), /* XFRLEN1 = 1 */
MCBSP_XCR1_XWDLEN1_16BIT /* XWDLEN1 = 2 */ ),
MCBSP_XCR2_RMK(
MCBSP_XCR2_XPHASE_SINGLE, /* XPHASE = 0 */
MCBSP_XCR2_XFRLEN2_OF(), /* 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 */
, /* 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
};
/* This next struct shows how to use the I2C API */
/* Create and initialize an I2C initialization structure */
I2C_Setup I2Cinit = {
, /* 7 bit address mode */
, /* own address - don't care if master */
, /* clkout value (Mhz) */
, /* a number between 10 and 400*/
, /* number of bits/byte to be received or transmitted (8)*/
, /* DLB mode on*/
/* FREE mode of operation on*/
}; I2C_Config testI2C; /*数字音频接口格式设置
AIC23为主模式,数据为DSP模式,数据长度16位*/
//Uint16 digital_audio_inteface_format[2]={0x0e,0x53};
Uint16 digital_audio_inteface_format[]={0x0e,0x43};
/*AIC23的波特率设置,采样率为44.1K*/
Uint16 sample_rate_control[] = {0x10,0x23};
/*AIC23寄存器复位*/
Uint16 reset[] ={0x1e,0x00};
/*AIC23节电方式设置,所有部分均所与工作状态*/
Uint16 power_down_control[] ={0x0c,0x00};
/*AIC23模拟音频的控制//DAC使能,ADC输入选择为麦克风*/
Uint16 analog_aduio_path_control[] ={0x08,0x17}; /*AIC23数字音频通路的控制*/
Uint16 digital_audio_path_control[] ={0x0a,0x05};
/*AIC23数字接口的使能*/
Uint16 digital_interface_activation[] ={0x12,0x01}; /*AIC23左通路音频调节*/
Uint16 left_line_input_volume_control[] ={0x00,0x17};
/*AIC23右通路音频调节*/
Uint16 right_line_input_volume_control[] ={0x02,0x17};
Uint16 left_headphone_volume_control[] ={0x04,0x79};
/*AIC23耳机右通路音频调节*/
Uint16 right_headphone_volume_control[] = {0x06,0x79};
/*定义McBSP的句柄*/
MCBSP_Handle hMcbsp; Uint16 i2c_status;
Uint16 i,temp; void delay(Uint32 k)
{
while(k--);
} void main(void)
{ Uint16 aic23data = ;
i2c_status = ;
/* Initialize CSL library - This is REQUIRED !!! */
/*初始化CSL库*/
CSL_init(); /*设置系统的运行速度为140MHz*/
PLL_config(&myConfig); /* Initialize I2C, using parameters in init structure */
/*初始化I2C的格式*/
/*I2C is undet reset*/
I2C_RSET(I2CMDR,);
/*设置预分频寄存器,I2C的mode clock is 10MHz*/
delay();
I2C_RSET(I2CSAR,0x001A);
I2C_RSET(I2CMDR,0x0620); I2C_setup(&I2Cinit);
/*设置I2C的Mater clock*/
I2C_RSET(I2CCLKL,);
I2C_RSET(I2CCLKH,); I2C_getConfig(&testI2C); /*初始化McBSP0*/
hMcbsp = MCBSP_open(MCBSP_PORT1,MCBSP_OPEN_RESET);
/*设置McBSP0*/
MCBSP_config(hMcbsp,&Mcbsp1Config);
/*启动McBSP0*/
MCBSP_start(hMcbsp,
MCBSP_RCV_START | MCBSP_XMIT_START,
); MCBSP_getConfig(hMcbsp,&Mcbsptest); /*reset AIC23*/
i2c_status = I2C_write( reset, //pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
delay();
/*设置AIC23各部分均工作*/
i2c_status = I2C_write( power_down_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置AIC23的数字接口*/
i2c_status = I2C_write( digital_audio_inteface_format,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置AIC23模拟通路*/
i2c_status = I2C_write( analog_aduio_path_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置数字通路*/
i2c_status = I2C_write( digital_audio_path_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置AIC23的采样率*/
i2c_status = I2C_write( sample_rate_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置耳机音量*/
i2c_status = I2C_write( left_headphone_volume_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
i2c_status = I2C_write( right_headphone_volume_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
/*设置Line输入的音量*/
i2c_status = I2C_write( left_line_input_volume_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
);
i2c_status = I2C_write( right_line_input_volume_control,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
); /*启动AIC23*/
i2c_status = I2C_write( digital_interface_activation,//pointer to data array
, //length of data to be transmitted
, //master or slaver
CODEC_ADDR, //slave address to transmit to
, //transfer mode of operation
//time out for bus busy
); /*回放音频*/
//每次读取256个字符,然后进行解析
//现在需要解决的问题是,1. 确定多久采样一次。2. 滤波的问题
//3. 从Line in输入改成麦克风 //进行FFT的初始化
InitForFFT(); while(TRUE)
{
while(!MCBSP_rrdy(hMcbsp)){};
aic23data = MCBSP_read16(hMcbsp);
MCBSP_write16(hMcbsp,aic23data); }
}

2. 上面调试的问题关键在于是TLV320AIC23的寄存器

3. 调试的时候发现,根本没声音,原来是这个寄存器写错了

Uint16 power_down_control[] ={0x0c,0x00};

一直不明白原来开发板为什么是0x03,很奇怪

4. 如果需要选择LINE IN的输入,那么代码需要修改为

//DAC使能,ADC输入选择为Line*/
Uint16 analog_aduio_path_control[] ={0x08,0x10};

5. 现在遇到的问题是,右声道噪音特别大,需要看下是什么原因,填写0x43的时候,右声道噪音特别大

AIC23为主模式,数据为DSP模式,数据长度16位*/
//Uint16 digital_audio_inteface_format[2]={0x0e,0x43};
Uint16 digital_audio_inteface_format[]={0x0e,0x53};

看下寄存器手册

DSP5509项目之用FFT识别钢琴音调(4)之麦克风输入和Line in输入的更多相关文章

  1. DSP5509项目之用FFT识别钢琴音调(1)

    1. 其实这个项目难点在于,能不能采集到高质量的钢琴音调.先看一下FFT相关程序. FFT 并不是一种新的变换,它是离散傅立叶变换(DFT)的一种快速算法.由于我们在计算 DFT 时一次复数乘法需用四 ...

  2. DSP5509项目之用FFT识别钢琴音调(2)

    1. 本节主要是学习TLV320AIC32这个音频芯片,Easy5509 开发板上有一个语音编解码芯片 TLV320AIC23.TLV320AIC23 是一个高性能的多媒体数字语音编解码器,它的内部 ...

  3. DSP5509项目之用FFT识别钢琴音调(5)之开始傅里叶变换

    1. 首先电脑上下载一个音频模拟的软件 2. 研究下钢琴的声音范围27HZ到4000HZ,那么采样频率需要是信号的两倍频率以上,所以建议采样频率是16KHZ.先看一下采集到的数据,如下是空载时候采集到 ...

  4. DSP5509项目之用FFT识别钢琴音调(3)之ccs v6环境变量的配置

    1. 添加头文件路径,没搞明白"${C5500_CSL_CG_ROOT}/include"里面的C5500_CSL_CG_ROOT是在哪里定义的? 2. 打开CCS的窗口,优选项配 ...

  5. 转:基于开源项目OpenCV的人脸识别Demo版整理(不仅可以识别人脸,还可以识别眼睛鼻子嘴等)【模式识别中的翘楚】

    文章来自于:http://blog.renren.com/share/246648717/8171467499 基于开源项目OpenCV的人脸识别Demo版整理(不仅可以识别人脸,还可以识别眼睛鼻子嘴 ...

  6. 在idea中打开maven项目pom.xml未识别

    在idea中打开maven项目pom.xml没有识别出来,导致idea不能自动下载依赖包, 解决办法是选中pom.xml文件,右键-" add as maven project"

  7. 解决IDEA导入Myclipse项目的时候没有识别为Web项目的问题

    IDEA在导入一个MyEclipse新建的Web项目的时候,一般会正确检测这个项目是什么项目.不过有时候会出现各种问题. 1. 出现一些Jar包不存在的问题,一般是servlet-api这样的包不存在 ...

  8. 通过调用API在JavaWeb项目中实现证件识别

    本文详细介绍自己如何在JavaWeb项目中通过调用API实现证件识别. 一,Face++使用简介 二,两种方式(图片URL与本地上传)实现证件识别 一,Face++使用简介 Face++旷视人工智能开 ...

  9. .Net下引用多目标框架项目导致XAML无法识别类型的问题

    背景 我的项目(以下称为LibA)中有一个多目标框架编译的项目,即项目文件包含如下代码: <PropertyGroup> ... <TargetFrameworks>netco ...

随机推荐

  1. iOS js 使用与JSContext

    JSContext:js执行环境,包含了js执行时所需要的所有函数和对象: js执行时,会在执行环境搜索需要的函数然后执行,或者保存传入的变量或函数: JSContext *jsContext = [ ...

  2. CCControlExtension/CCControl

    #ifndef __CCCONTROL_H__ #define __CCCONTROL_H__ #include "CCInvocation.h" #include "C ...

  3. 死磕salt系列-salt 常用modules

    saltstack 常用模块介绍 file模块 被控主机文件常见操作,包括文件读写.权限.查找.校验等 salt '*' file.get_sum /etc/resolv.conf md5 salt ...

  4. Spring JPA 主键

    JPA主键生成器和主键生成策略 JPA中创建实体时,需要声明实体的主键及其主键生成策略.我们有一个实体类叫做Email,其主键上声明如下: @Id @Column(name = "EMAIL ...

  5. 随手练——O(n)解决无序数组排序后的相邻最大差值

    题目从这儿看到的 : https://mp.weixin.qq.com/s/2OXg67MfBuQjDPAJxxD8rQ,但是公众号上讲错了,问题还挺严重的. 题目知识点:桶排序. 题目:有一个无序数 ...

  6. 2.4G电动车防盗方案 超低功耗单发器 SI24R2F

           对于现在的电动车防盗标签和校园卡的市场,主要以2.4G为主做标签,各色各样的2.4G国产芯片渐渐的能满足这块RFID领域.但是作为RFID的推动领导者,深圳市动能世纪科技有限公司专注于超 ...

  7. 程序员职业规划(一篇来自"阿里Java工程师"对工作3年左右程序员的职业建议和应该掌握的职业技能)

    程序员的三个阶段(转载) 第一阶段:三年 我认为三年对于程序员来说是第一个门槛,这个阶段将会淘汰掉一批不适合写代码的人. 这一阶段,我们走出校园,迈入社会,成为一名程序员,正式从书本上的内容迈向真正的 ...

  8. CodeForces - 999D Equalize the Remainders (模拟+set)

    You are given an array consisting of nn integers a1,a2,…,ana1,a2,…,an , and a positive integer mm . ...

  9. POJ 1050 To the Max 最大子矩阵和(二维的最大字段和)

    传送门: http://poj.org/problem?id=1050 To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submi ...

  10. version 1.5.2-04 of the jvm is not suitable for this product. version:1.6 or greater is required

    这里仅仅说明一个可能造成该问题的解决办法,也是我遇到的原因. 这句话的意思是说,eclipse须要至少1.6版本号或以上的JVM ,而你仅仅有1.5.2版本号的JVM.想想就认为非常奇怪,我装的但是J ...