DSP I2C读写ADS1015时,如果一直读或者一直写,会一直停在while(I2caRegs.I2CSTR.bit.XRDY == 0),求Ti大牛帮忙看一下。跪谢

I2C初始化

void I2CA_Init(void)
{
// Initialize I2C
I2caRegs.I2CSAR = 0x0020; // Slave address - EEPROM control code

I2caRegs.I2CPSC.all = 7; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 10; // NOTE: must be non zero
I2caRegs.I2CCLKH = 5; // NOTE: must be non zero
I2caRegs.I2CIER.all =0x00; //0x24; // Enable SCD & ARDY interrupts

I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended

I2caRegs.I2CFFTX.all = 0x00;//0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x00;//0x2040; // Enable RXFIFO, clear RXFFINT,

return;
}

I2C写函数

void I2CA_SendData(struct I2CMSG *msg,Uint16 addr,Uint16 type,Uint16 data)
{
Uint16 i;
while(I2caRegs.I2CMDR.bit.STP ==1);
I2caRegs.I2CSAR = addr; //Set slave address
while(I2caRegs.I2CSTR.bit.BB == 1);
I2caRegs.I2CCNT = 3; //Set count to 5 characters plus 2 address bytes
I2caRegs.I2CDXR = type; //Send eeprom high address
// I2caRegs.I2CMDR.bit.TRX = 1; //Set to Transmit mode
// I2caRegs.I2CMDR.bit.MST = 1; //Set to Master mode
// I2caRegs.I2CMDR.bit.FREE = 1; //Run in FREE mode
// I2caRegs.I2CMDR.bit.STP = 1; //Stop when internal counter becomes 0
// I2caRegs.I2CMDR.bit.STT = 1; //Send the start bit, transmission will follow
// while(I2caRegs.I2CSTR.bit.XRDY == 0){}; //Do nothing till data is shifted out
// I2caRegs.I2CDXR = type; //Send eeprom low address
I2caRegs.I2CMDR.all = 0x6E20;
for(i = 0; i < 2; i++){
while(I2caRegs.I2CSTR.bit.XRDY == 0){}; //Do nothing till data is shifted out
// while(I2caRegs.I2CFFTX.bit.TXFFST == 16);
I2caRegs.I2CDXR = data>>((1-i)*8); //Send out the message
}
}

在for(;;)

{

LoopCount++;

if (LoopCount >4000)

{

LoopCount =0;

I2CA_SendData()

}

具体为这样操作的,但是写一段时间会停在while(I2caRegs.I2CSTR.bit.XRDY == 0){};此处,求大牛帮忙看一下

}

2 个回复