Other Parts Discussed in Thread: TMS320F28035, CONTROLSUITE
Am trying to read MPU9150 sensors values through I2c by using TMS320F28035 piccolo [GPIO28 and GPIO29],my problem is I don't see the activity on SCL line however. As the pin was initially high, as soon as the code is run, the SCL goes low and stays low. It's not pulsing at all. I'm not seeing SDATA doing any activity either. It stays as it is, high.
So this code is what I come with
//**************I2c initialization
void I2CA_Init(void)
{
I2caRegs.I2CMDR.all = 0x0000;
I2caRegs.I2CSAR = 0x68;
I2caRegs.I2CPSC.all = 6;
I2caRegs.I2CCLKL = 10;
I2caRegs.I2CCLKH = 5;
I2caRegs.I2CIER.all = 0x3E;
I2caRegs.I2CMDR.all = 0x0020;
I2caRegs.I2CFFTX.all = 0x6000;
I2caRegs.I2CFFRX.all = 0x2040;
return;
}
//************WRITE FUNCTION
void writeRegisterWithPiccolo(char reg,char write_data,char stop_bit)
{
while(I2caRegs.I2CMDR.bit.STP == 1) { //// wait until the STP bit is cleared from any previous master communication
}
while (I2caRegs.I2CSTR.bit.BB == 1) { // wait until bus not busy
}
// Setup slave address
I2caRegs.I2CSAR = MPU9150_I2C_ADDR;
// Setup number of bytes to send
I2caRegs.I2CCNT = 2;
// Setup data to send
I2caRegs.I2CDXR = reg;
I2caRegs.I2CDXR = write_data;
if(stop_bit == 'y') // if there should be a stop bit at the end of transmission, then
{
while(I2caRegs.I2CMDR.all != 0x6E20){
I2caRegs.I2CMDR.all = 0x6E20; // send start as master transmitter, w/ stop condition once all bytes have been sent
}
while(I2caRegs.I2CSTR.bit.SCD != 1) {} // wait until stop condition is detected
I2caRegs.I2CSTR.bit.SCD = 1; // clear stop condition detected bit in I2C status register
}
else // if there should not be a stop condition at end of transmission (master retains control of bus), then
{
while(I2caRegs.I2CMDR.all != 0x2620){
I2caRegs.I2CMDR.all = 0x2620; // start condition, master mode, TX mode
}
while(I2caRegs.I2CSTR.bit.ARDY != 1) {} // wait for I2C registers to finish working
I2caRegs.I2CSTR.bit.ARDY = 1; // clear ARDY bit in I2C status register
}
}
//***************READ FUNCTION
unsigned short readRegisterWithPiccolo(unsigned char reg)
{
while(I2caRegs.I2CMDR.bit.STP == 1) { //// wait until the STP bit is cleared from any previous master communication
}
I2caRegs.I2CSAR = MPU9150_I2C_ADDR;
// Check if bus busy
while (I2caRegs.I2CSTR.bit.BB == 1){ // wait until bus not busy
}
I2caRegs.I2CCNT = 1;
I2caRegs.I2CDXR = reg;
while(I2caRegs.I2CMDR.all != 0x2620)
{
I2caRegs.I2CMDR.all = 0x2620; // Send data to setup MEMS address
}
I2caRegs.I2CCNT = 2; // Setup how many bytes to expect
while(I2caRegs.I2CMDR.all != 0x2C20)
{
I2caRegs.I2CMDR.all = 0x2C20; // 0x2C20 --Send restart as master receiver
}
return I2caRegs.I2CDRR;
}
PLEASE help me
