AnsweredAssumed Answered

AD5933 i2c problems

Question asked by impedance33 on Jul 6, 2015
Latest reply on Jul 16, 2015 by mcee

Hello,

I have problems with i2c communication. My program sometimes work however other times while I am debugging a simple i2c project it always read 0x00 from every register.

I just have 2 functions, one to write and the other to read. In main, I call this functions, first writing and then reading the same register.

Another issue is that when I am debugging "Step Into" button all works fine, but if I debug with "Step over" it doesn´t work properly and take differents results or just don't change from zero.

I have tried many times and always the same problem. Do you know what is happening?

The part code involved is:
.......
i2c_write(0x82,0x0A,1);
datorecibido=i2c_read(0x82);
.........
.........
void i2c_write(uint8_t register_address,uint32_t register_data,uint8_t nbytes){
if(nbytes==1){
I2CMasterSlaveAddrSet(I2C1_BASE, 0x0D,false);
I2CMasterDataPut(I2C1_BASE, register_address);
I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C1_BASE)){}
uint8_t register_data1= register_data;
I2CMasterDataPut(I2C1_BASE, register_data1);
I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);
while(I2CMasterBusy(I2C1_BASE)){}
}
while(I2CMasterErr(I2C1_BASE) != I2C_MASTER_ERR_NONE){}
return;
}
uint32_t i2c_read(uint8_t register_address){
I2CMasterSlaveAddrSet(I2C1_BASE, 0xD,true);
I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_SINGLE_RECEIVE);
data = I2CMasterDataGet(I2C1_BASE);
return data;
}
.......

 

When I debug this clicking on "Step into" or F5 -> datorecibido=0x0A
But clicking on "Step over" or F6 ->datorecibido=0x00

If I click on "Resume" and then "Pause", the program is in a while(1) interrupt :

//This is the code that gets called when the processor receives a fault
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
FaultISR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}

It's very extrange! Do you know why?

Since this happened, Now I have the program stopped in the first while(I2CMasterBusy(I2C1_BASE)){}.

I have no idea about why the bus is busy. Any idea?

Thanks!

Outcomes