Hi,
I have another problem with I2C in DM642. The following is my code:
I2C_Handle hI2c;
I2C_Config i2cCfg;
com_init();
CHIP_config( &chipConfig ); //enable I2C module in PERCFG register
CHIP_config( &chipConfig ); //enable I2C module in PERCFG register
hI2c = I2C_open(I2C_DEV0, I2C_OPEN_RESET);
if ( hI2c != INV )
{
I2C_config(hI2c, &mycfgData); //Configure the I2C module
I2C_FSETH(hI2c, I2CMDR, IRS, 1); //enable the I2C module
if (!I2C_bb(hI2c)) //busy?
{
I2C_start(hI2c); //set the STT bit
I2C_writeByte(hI2c, 0x90); //write the slave address
while( !I2C_FGETH(hI2c,I2CSTR,NACK) ) //receive ACK signal
{
puts("success!"); //succeeding transfer the slave address
I2C_sendStop(hI2c); //generate STOP signal
}
{
I2C_config(hI2c, &mycfgData); //Configure the I2C module
I2C_FSETH(hI2c, I2CMDR, IRS, 1); //enable the I2C module
if (!I2C_bb(hI2c)) //busy?
{
I2C_start(hI2c); //set the STT bit
I2C_writeByte(hI2c, 0x90); //write the slave address
while( !I2C_FGETH(hI2c,I2CSTR,NACK) ) //receive ACK signal
{
puts("success!"); //succeeding transfer the slave address
I2C_sendStop(hI2c); //generate STOP signal
}
I2C_sendStop(hI2c);
I2C_close(hI2c); //Close I2C0 Module
Strangely, after executing "I2C_start(hI2c)", I only can see the SCL turne
to be low, while the SDA remains high. Furthermore, there is no clock signal on
the SCL line and no ACK from the receiver.
Is there anything that I should do to initiate the I2C module? or there is
some problem with my I2C module or DSP?
Thank you very much!
Victorwang
V...@yahoo.com.cn
2005-09-26
һʼɧbr /> ɱ