简体   繁体   English

通过I2C与ROHM BU94603对话

[英]Talk to ROHM BU94603 via I2C

I am trying to write a simple program to communicate with ROHM BU94603KV Audio Decoder IC. 我正在尝试编写一个与ROHM BU94603KV音频解码器IC进行通信的简单程序。 The host controller I use is Atmega8. 我使用的主机控制器是Atmega8。 The language is C. 语言是C。

BU94603KV is AAC+WMA + MP3 decoder IC which contains USB host, SD card I/F, audio DAC, system controller, and regulator for internal CORE power supply. BU94603KV是AAC + WMA + MP3解码器IC,包含USB主机,SD卡I / F,音频DAC,系统控制器和用于内部CORE电源的调节器。

I setup the hardware for MANUAL SLAVE MODE which can send the memory device information to the master microcomputer via the I2C interface and completely control sequences such as a play sequence by the master microcomputer (referred to as MODE3). 我为MANUAL SLAVE MODE设置了硬件,该硬件可以通过I2C接口将存储设备信息发送到主微机,并完全控制诸如主微机的播放序列之类的序列(称为MODE3)。

I'm trying to write a shortest test code for sanity checking. 我正在尝试编写最短的测试代码以进行健全性检查。 To do that, I write 0x5E and 0x03 to BU94603KV via I2C (Comand to read EQINF register). 为此,我通过I2C(命令读取EQINF寄存器)将0x5E和0x03写入BU94603KV。 Everything seem to work correctly (no error return code form the I2C routine). 一切似乎都能正常工作(I2C例程没有错误返回代码)。 However, the result is not what expected. 但是,结果不是预期的。

Here is my source code; 这是我的源代码;

unsigned char BU94603_Read_Test(void){

unsigned char errorStatus;

errorStatus = i2c_start();
if(errorStatus == 1)
{
    i2c_stop();
    return(-1);
}

// STEP1 send command to read EQ ----------------------
while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_sendAddress(BU94603_WRITE_ADDRESS);
if(errorStatus == 1)
{
    i2c_stop();
    return(-2);
}

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_sendData(BU94603_READ_STAT);
if(errorStatus == 1)
{
    i2c_stop();
    return(-3);
}

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_sendData(BU94603_READ_EQ);
if(errorStatus == 1)
{
    i2c_stop();
    return(-4);
}
i2c_stop();

// STEP2 read EQ status --------------------------
errorStatus = i2c_start();
if(errorStatus == 1)
{
    i2c_stop();
    return(-5);
}

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_sendAddress(BU94603_READ_ADDRESS);
if(errorStatus == 1)
{
    i2c_stop();
    return(-6);
}

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_receiveData_ACK();
if(errorStatus == ERROR_CODE)
{
    i2c_stop();
    return(-7);
}

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_receiveData_NACK();
if(errorStatus == ERROR_CODE)
{
    i2c_stop();
    return(-7);
}   

while((PINC & (1<<BU94603_BUSY)));  // wait while BU94603 is busy
errorStatus = i2c_receiveData_NACK();
if(errorStatus == ERROR_CODE)
{
    i2c_stop();
    return(-7);
}   

i2c_stop();
return(errorStatus);

} }

The running result is 0xFB (supposed to be 0x40). 运行结果为0xFB(假定为0x40)。 What could be the problem? 可能是什么问题呢?

Having return status and returned data in the same value is maybe a bit weird, especially when they can overlap. 将返回状态和返回的数据设置为相同的值可能有点奇怪,尤其是当它们可以重叠时。

Anyway, 0xfb is -5, so it looks like you have an issue with second i2c_start() failing. 无论如何,0xfb是-5,所以看来您有第二个i2c_start()失败的问题。 It might be that a loop waiting for BU94603 to be ready again is needed. 可能是需要等待BU94603重新准备好的循环。

You didn't describe any pin configuration (usually you need to set pins to i2c mode), and also nothing on hardware side (common issue for a beginner would be missing pull-ups). 您没有描述任何引脚配置(通常需要将引脚设置为i2c模式),在硬件方面也没有任何内容(对于初学者来说,常见的问题是缺少上拉电阻)。

Do you have access to any hardware debugging tools (oscilloscope maybe)? 您可以使用任何硬件调试工具(也许是示波器)吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM