在使用c55_csl_3.06 CSL_I2C_CodecTestExample调试过程中,当DSP作为Master模式下,通过添加打印log,发现第一次I2C卡在
statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR,I2C_ICSTR_ICRRDY);下,无法ICRRDY为1的信号。后续在I2C_ICSTR_BB就一直timeout、
时钟输入是按照晶振配置为12M 输出频率为10K。请问有可能是哪里出了问题?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在使用c55_csl_3.06 CSL_I2C_CodecTestExample调试过程中,当DSP作为Master模式下,通过添加打印log,发现第一次I2C卡在
statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR,I2C_ICSTR_ICRRDY);下,无法ICRRDY为1的信号。后续在I2C_ICSTR_BB就一直timeout、
时钟输入是按照晶振配置为12M 输出频率为10K。请问有可能是哪里出了问题?
没有在GEL文件中设置。请问GEL文件指的具体是哪一个文件,我这边没有看到gel对应后缀的文件
SDA SCL管脚已上拉3.3v
可以运行到CSL_testRegister
以下为我修改的I2C_write函数
CSL_Status I2C_write(Uint16 *i2cWrBuf,
Uint16 dataLength,
Uint16 slaveAddr,
Bool masterMode,
Uint16 startStopFlag,
Uint16 timeout)
{
volatile Uint16 looper;
Uint16 dataCount;
Uint16 statusByte;
if((i2cWrBuf != NULL) && (dataLength !=0))
{
/* check for bus busy */
for(looper = 0; looper < timeout; looper++)
{
statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR, I2C_ICSTR_BB);
if(statusByte == FALSE)
{
printf("bus busy\n");
break;
}
}
if(looper >= timeout)
{
printf("bus busy timeout\n");
/* bus busy timeout error */
return(CSL_I2C_BUS_BUSY_ERR);
}
/* Set the Tx mode */
CSL_FINST(i2cHandle->i2cRegs->ICMDR, I2C_ICMDR_TRX, SET);
/* Set the data length */
CSL_FINS(i2cHandle->i2cRegs->ICCNT, I2C_ICCNT_ICDC, dataLength);
if(masterMode == TRUE)
{
printf("masterMode\n");
/* Set the slave address */
CSL_FINS(i2cHandle->i2cRegs->ICSAR, I2C_ICSAR_SADDR, slaveAddr);
/* Enable Master mode */
CSL_FINST(i2cHandle->i2cRegs->ICMDR, I2C_ICMDR_MST, SET);
/* Set the stop bit */
if((startStopFlag & CSL_I2C_STOP) == CSL_I2C_STOP)
{
printf("set stop bit\n");
CSL_FINST(i2cHandle->i2cRegs->ICMDR, I2C_ICMDR_STP, SET);
}
/* Set the start bit */
if((startStopFlag & CSL_I2C_START) == CSL_I2C_START)
{
printf("set start bit\n");
CSL_FINST(i2cHandle->i2cRegs->ICMDR, I2C_ICMDR_STT, SET);
}
}
else
{
printf("slave mode\n");
/* Disable Master mode */
CSL_FINST(i2cHandle->i2cRegs->ICMDR, I2C_ICMDR_MST, CLEAR);
}
for(dataCount = 0; dataCount < dataLength; dataCount++)
{
/* Check for ICXRDY status */
for(looper = 0; looper < timeout; looper++)
{
statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR,
I2C_ICSTR_ICXRDY);
// statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR,
// I2C_ICSTR_ICRRDY);
if(statusByte == TRUE)
{
break;
}
}
if(looper >= timeout)
{
printf("CSL_I2C_TIMEOUT_ERROR\n");
return(CSL_I2C_TIMEOUT_ERROR);
}
/* Write data to the data Tx register */
CSL_FINS(i2cHandle->i2cRegs->ICDXR, I2C_ICDXR_D, *i2cWrBuf++);
for(looper = 0; looper < timeout; looper++)
{
/* Check for NACK status */
statusByte = CSL_FEXT(i2cHandle->i2cRegs->ICSTR,
I2C_ICSTR_NACK);
if(statusByte == FALSE)
{
break;
}
}
if(looper >= timeout)
{
printf("CSL_I2C_NACK_ERR\n");
return(CSL_I2C_NACK_ERR);
}
}
}
else
{
printf("CSL_ESYS_INVPARAMS\n");
return(CSL_ESYS_INVPARAMS);
}
return(CSL_SOK);
}
第一次可以运行等待data received 超时 后面在bus busy 超时
Log如下
CSL_testRegister
I2C CODEC CONFIGURING IN POLLED MODE TEST!
pscValue:8
clock:57
CSL_testRegister
bus busy
masterMode
set stop bit
set start bit
CSL_I2C_TIMEOUT_ERROR
I2C Write Failed!!
Read Write Buffers Don't Match for Register:0 with Value:0
CSL_testRegister Failed!!
CSL_testRegister
bus busy timeout
I2C Write Failed!!
Read Write Buffers Don't Match for Register:65 with Value:81
CSL_testRegister Failed
I2C是先发最高位MSB的,抓取到的数据没问题。
The data is always transferred with the mostsignificant bit (MSB) first.
www.ti.com/.../spruh87h.pdf
目前I2C配置正常可以成功读写。总结一下I2C调试相关内容:
环境 CCS6.1.3 demo库使用c55_csl_3.06的CSL_I2C_CodecTestExample。硬件使用的是TMS320C5517+PCM1864
1.修改CSL_I2C_DATA_SIZE的定义,由64修改为16(参考codec数据手册对应修改)
2.修改CSL_I2C_SYS_CLK为100(M),C5517支持0~175M时钟,保证I2C presaler 6.7M-13.3M区间,CSL_I2C_CodecTestExample是12分频,分频后为8M(整型)。
3.CSL_I2C_CODEC_ADDR地址配置,PCM1864为7bit slave地址,但是写的为8bit地址 所以写入时需要右移一位。I2C address 0x94 配置为0x4A