各位仁兄,本人最近用SEED公司的DSP6713的I2C0控制TLV320AIC23B的寄存器时,程序调试总出现问题,现贴出来,做过这方面的仁兄请指导一下:
#include <csl.h>
#include <csl_i2c.h>
#include <csl_irq.h>
#include "DEC6713.h"
#include "aic23.h"
#include <stdio.h>
/********************************************************************************/
/* Set I2C registers. */
I2C_Config MyI2CCfgT = {
I2C_FMKS(I2COAR,A,OF(0x00)), //Not used if master.
I2C_FMKS(I2CIMR,ICXRDY,MSK) |
I2C_FMKS(I2CIMR,ICRRDY,MSK) |
I2C_FMKS(I2CIMR,ARDY,MSK) |
I2C_FMKS(I2CIMR,NACK,MSK) |
I2C_FMKS(I2CIMR,AL,MSK),
/* Master clock frequency is 200kHz(SYSCLK2 is 150MHz). */
I2C_FMKS(I2CCLKL,ICCL,OF(14)),
I2C_FMKS(I2CCLKH,ICCH,OF(14)),
I2C_FMKS(I2CCNT,ICDC,OF(20)),
I2C_FMKS(I2CSAR,A,OF(26)),
I2C_FMKS(I2CMDR,FREE,RFREE) |
I2C_FMKS(I2CMDR,STT,START) |
I2C_FMKS(I2CMDR,MST,MASTER) |
I2C_FMKS(I2CMDR,TRX,XMT) |
I2C_FMKS(I2CMDR,RM,REPEAD) |
I2C_FMKS(I2CMDR,IRS,NRST) |
I2C_FMKS(I2CMDR,FDF,NONE) |
I2C_FMKS(I2CMDR,BC,BIT8FDF) |
I2C_FMKS(I2CMDR,STB,NONE),
I2C_FMKS(I2CPSC,IPSC,OF(15-1))
};
I2C_Config MyI2CCfgR = {
I2C_FMKS(I2COAR,A,OF(0x00)),
I2C_FMKS(I2CIMR,ICXRDY,MSK) |
I2C_FMKS(I2CIMR,ICRRDY,MSK) |
I2C_FMKS(I2CIMR,ARDY,MSK) |
I2C_FMKS(I2CIMR,NACK,MSK) |
I2C_FMKS(I2CIMR,AL,MSK),
/* Master clock frequency is 200kHz(SYSCLK2 is 150MHz). */
I2C_FMKS(I2CCLKL,ICCL,OF(19)),
I2C_FMKS(I2CCLKH,ICCH,OF(19)),
I2C_FMKS(I2CCNT,ICDC,OF(1)),
I2C_FMKS(I2CSAR,A,OF(0)),
I2C_FMKS(I2CMDR,FREE,RFREE) |
I2C_FMKS(I2CMDR,MST,MASTER) |
I2C_FMKS(I2CMDR,TRX,RCV) |
I2C_FMKS(I2CMDR,IRS,NRST) |
I2C_FMKS(I2CMDR,STB,NONE),
I2C_FMKS(I2CPSC,IPSC,OF(15-1))
};
Uint16 I2C_write16(I2C_Handle hI2C,Uint8 regnum,Uint8 regval)
{
Uint8 tempdata = 0;
//Waiting for Bit12 of ICSTR ie. BB (Bus Busy) to clear
waitForBusFree(hI2C);
/* Configure I2C. */
I2C_config(hI2C,&MyI2CCfgT);
//Write the low data into Data Transmit register
tempdata = regnum;
I2C_writeByte(hI2C, tempdata&0xFF);
//To invoke the start condition
I2C_start(hI2C);
/* Wait until MSB transmit is done */
while(!I2C_xrdy(hI2C));
//Write the high data into Data Transmit register.
tempdata = regval;
I2C_writeByte(hI2C, tempdata&0xFF);
//Generate Stop condition
I2C_sendStop(hI2C);
//Waiting for Bit12 of ICSTR ie. BB (Bus Busy) to clear
waitForBusFree(hI2C);
return TRUE;
}
extern far void vectors();
I2C_Handle hI2c;
void main()
{
CSL_init();
/* Initialize DEC6713 board. */
DEC6713_init();
IRQ_setVecs(vectors);
IRQ_nmiEnable();
IRQ_globalEnable();
hI2c = I2C_open(I2C_DEV0,I2C_OPEN_RESET);
/* Configure I2C. */
// I2C_config(hI2c,&MyI2CCfgT);
// I2C_config(hI2c,&MyI2CCfgT);
//左通道音量控制
I2C_write16(hI2c,0x00,0x17);
//右通道音量控制
I2C_write16(hI2c,0x02,0x17);
//左通道麦克风音量控制
I2C_write16(hI2c,0x05,0xFF);
//右通道麦克风音量控制
I2C_write16(hI2c,0x07,0xFF);
//模拟音频路径控制
I2C_write16(hI2c,0x08,0x0C);
//数字音频路径控制
I2C_write16(hI2c,0x0B,0x00);
//电源控制
I2C_write16(hI2c,0x0D,0xFF);
//数字端口模式控制
I2C_write16(hI2c,0x0E,0x02);
//采样频率控制
I2C_write16(hI2c,0x10,0x0D);
//数字端口开启控制
I2C_write16(hI2c,0x12,0x01);
while(1){};
}
我本想通过IIC0来配置AIC23B的寄存器,使AIC23B为Bypass模式,这样就可以直接将音频信号输出来,以验证AIC23B配置的正确.可总也出不来,不知道哪位知道原因,请指教. |