1. 本次使用LINE_IN作为输入,LINE_OUT作为输出(可以插耳机),代码如下,代码经过测试,没问题,不过发现了一个很奇怪的问题没搞明白

/******************************************************************************/
/* Copyright 2004 by SEED Electronic Technology LTD. */
/* All rights reserved. SEED Electronic Technology LTD. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/* */
/* */
/******************************************************************************/
/*----------------------------------------------------------------------------*/
/* DESCRIPTION: */
/* */
/* This is an example for EMIF of C5509 */
/*----------------------------------------------------------------------------*/
/* MODULE NAME... I2C and Mcbsp */
/* FILENAME...... codec.c */
/* DATE CREATED.. Mon 02/4/2004 */
/* COMPONENT..... */
/* PREREQUISITS.. */
/*----------------------------------------------------------------------------*/
/* DESCRIPTION: */
/* */
/* this example is that the codec is controled by the I2C and Mcbsp */
/*----------------------------------------------------------------------------*/ #include <csl.h>
#include <csl_i2c.h>
#include <stdio.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>
#include <csl_gpio.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)
}; 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左通路音频调节*/
Uint16 left_line_input_volume_control[] ={0x00,0x17};
/*AIC23右通路音频调节*/
Uint16 right_line_input_volume_control[] ={0x02,0x17}; /*数字音频接口格式设置
AIC23为主模式,数据为DSP模式,数据长度16位*/
Uint16 digital_audio_inteface_format[]={0x0e,0x53};
/*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[2] ={0x08,0x17};
//LINE IN输入
Uint16 analog_aduio_path_control[] ={0x08,0x10};
/*AIC23数字音频通路的控制*/
Uint16 digital_audio_path_control[] ={0x0a,0x05};
/*AIC23数字接口的使能*/
Uint16 digital_interface_activation[] ={0x12,0x01}; ///*AIC23耳机左通路音频调节*/
//Uint16 left_headphone_volume_control[2] ={0x05,0xFF};
///*AIC23耳机右通路音频调节*/
//Uint16 right_headphone_volume_control[2] = {0x07,0xFF}; /*AIC23耳机左通路音频调节*/
Uint16 left_headphone_volume_control[] ={0x04,0x7f};
/*AIC23耳机右通路音频调节*/
Uint16 right_headphone_volume_control[] = {0x06,0x7f};
/*定义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);
/*确定方向为输出*/
GPIO_RSET(IODIR,0xFF);
GPIO_RSET(IODATA,0x00);
/* Initialize I2C, using parameters in init structure */
/*初始化I2C的格式*/ // I2C_config(&Config);
// I2C_start(); // I2C_getConfig(&Config1);
/*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
);
delay();
/*设置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
);
delay();
/*设置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
);
delay();
/*设置数字通路*/
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
);
delay();
/*设置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
);
delay();
/*设置耳机音量*/
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
);
delay();
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
);
delay();
/*设置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
);
delay();
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
);
delay();
/*启动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
);
delay();
/*回放音频*/
while(TRUE)
{
while(!MCBSP_rrdy(hMcbsp)){};
aic23data = MCBSP_read16(hMcbsp);
//aic23data = 0;
MCBSP_write16(hMcbsp,aic23data);
}
}

在其中一个寄存器不设置的时候,仿真停止的时候,音乐还能播放,如果设置的话,仿真停止的时候,音乐不能播放

TMS320VC5509驱动TLV32AIC23的更多相关文章

  1. TMS320VC5509驱动LCD1602

    1. 本次使用5509芯片的EMIF接口,先看下硬件的接口 LCD1602接口  RS(高电平1数据寄存器,低电平0指令寄存器) 接A2接口 LCD1602接口  RW(高电平读,低电平写) 接 AW ...

  2. TMS320VC5509驱动LCD1602之奇怪问题和时序图

    1. 最近调试自己板子上LCD1602的时候,看下测试的时序图,因为下面的时序图导致LCD1602无法显示,下面的时序图是有问题的,E的上升沿和下降沿的时候,RW需要低电平 对比下淘宝上买的可以显示的 ...

  3. TMS320VC5509驱动AT24C02

    1. 刚开始的波形不太对,比如如下代码 i2c_status = I2C_write( at24c02_write_buf, //pointer to data array , //length of ...

  4. TMS320VC5509驱动74HC595芯片

    1. 5509A有3个MCBSP模块,其中模块MCBSP可以配置成SPI模式,不过实际使用的时候需要把CLKX1和CLKR1接在一起,暂时没搞明白原因 MCBSP有6个引脚,DR0 RX0 作为数据的 ...

  5. TMS320VC5509总线驱动LED灯

    1. 重新建立的工程,需要添加宏定义才行 CHIP_5509 2. 驱动LED用的是74LVC573锁存器,LE高电平时,Q1=D0,LE低电平时,Q1=之前的状态,下面是数据总线 看下地址总线 看下 ...

  6. 领域驱动和MVVM应用于UWP开发的一些思考

    领域驱动和MVVM应用于UWP开发的一些思考 0x00 起因 有段时间没写博客了,其实最近本来是根据梳理的MSDN上的资料(UWP开发目录整理)有条不紊的进行UWP学习的.学习中有了心得体会或遇到了问 ...

  7. 浅谈我对DDD领域驱动设计的理解

    从遇到问题开始 当人们要做一个软件系统时,一般总是因为遇到了什么问题,然后希望通过一个软件系统来解决. 比如,我是一家企业,然后我觉得我现在线下销售自己的产品还不够,我希望能够在线上也能销售自己的产品 ...

  8. “四核”驱动的“三维”导航 -- 淘宝新UI(需求分析篇)

    前言 孔子说:"软件是对客观世界的抽象". 首先声明,这里的"三维导航"和地图没一毛钱关系,"四核驱动"和硬件也没关系,而是为了复杂的应用而 ...

  9. DDD 领域驱动设计-看我如何应对业务需求变化,愚蠢的应对?

    写在前面 阅读目录: 具体业务场景 业务需求变化 "愚蠢"的应对 消息列表实现 消息详情页实现 消息发送.回复.销毁等实现 回到原点的一些思考 业务需求变化,领域模型变化了吗? 对 ...

随机推荐

  1. MySQL 5.7 Reference Manual】15.4.2 Change Buffer(变更缓冲)

    15.4.2 Change Buffer(变更缓冲)   The change buffer is a special data structure that caches changes to se ...

  2. MySQL Bug导致异常宕机的分析流程

    原文链接:http://click.aliyun.com/m/42521/ 摘要: 本文主要通过一个bug来记录一下如何分析一个MySQL bug的崩溃信息. 版本:Percona 5.7.17-11 ...

  3. 2. 跟踪标记 (Trace Flag) 3604, 3605 输出DBCC命令结果

    跟踪标记:3604 功能: 输出DBCC命令返回结果到查询窗口(通常是SSMS窗口),类似print命令的显示效果: 用途: 常用于获取DBCC IND, DBCC PAGE命令的输出结果,因为这2个 ...

  4. 记录Ubuntu14.04 LTS版本中使用Docker的过程

    sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-p ...

  5. 固定UILabel宽度分行显示

    固定UILabel宽度分行显示 这种小伎俩估计都被用烂了,笔者给大家提供一个category文件,供大家简单设置哦. 各种富文本效果哦(普通文本也是可以用的呢): 3行,固定宽度200 2行,固定宽度 ...

  6. UNIX高级环境编程(4)Files And Directories - umask、chmod、文件系统组织结构和链接

    本篇主要介绍文件和文件系统中常用的一些函数,文件系统的组织结构和硬链接.符号链接. 通过对这些知识的了解,可以对Linux文件系统有更为全面的了解.   1 umask函数 之前我们已经了解了每个文件 ...

  7. EF CodeFirst下的自动迁移

    当我们修改数据模型,添加一个如下字段 再次运行程序,会因为数据库结构与模型不一致而报错 为解决以上错误可以采取以下三种方式 1.  删除数据库,重新运行站点,会重新生成数据库,这样就会丢失数据 2.  ...

  8. python---九九乘法表代码

    #_*_ coding:utf-8 _*_# author choco ''' #while循环num1=0while num1<9: num1+=1 num2=1 while num2< ...

  9. Zabbix日常监控(触发器表达式、远程执行命令、宏简等)简单记录

    主机的工作基本流程 Host group --> Host --> Application --> Item --> Trigger(OK-->PROBLEM,trigg ...

  10. WCF自寄宿实现Https绑定

    一.WCF配置 1 Address 将服务端发布地址和客户端访问地址都配置为https开始的安全地址.参考如下. <add key="SrvUrl" value=" ...