Hi all,
I am trying to interface a BMA255 acceleromter with the CSR1010. I have the i2c communication setup properly and I can send command to write and read the registers of the BMA255 via I2C.
I am using the i2c_comms.c and i2c_comms.h files as provided in the software examples. The sequence of i2c communication is as follows:
/* Acquire I2C bus */
if(I2CAcquire())
{
/* Initialise I2C communication. */
I2CcommsInit();
success = I2CWriteRegister(BMA250_I2C_ADDRESS, REG_BANDWIDTH,0x0F); // this works!
....
I2CRelease();
}
All the commands to configure the accelerometer works well except that I am unable to set the accelerometer to low power mode 1 by writing a value of 0x56 to register location 0x11.
success = I2CWriteRegister(BMA250_I2C_ADDRESS, 0x11,0x65); // this does not work
In the data sheet of the BMA255, there is a note on i2c access restrictions:
An interface idle time of at least 2us is required following a write operation when the device operates in normal mode (or standby mode, or low-power mode 2). In suspend mode (or low-power mode 1) an interface idle time of least 450us is required.
I am pretty sure its due to this 450us restriction. But I have no idea where to set the 450us idle time.
This is inside the I2CWriteRegister function:
*************************************************************************************
success = ( (I2cRawStart(TRUE) == sys_status_success) &&
(I2cRawWriteByte(base_address) == sys_status_success) &&
(I2cRawWaitAck(TRUE) == sys_status_success) &&
(I2cRawWriteByte(reg) == sys_status_success) &&
(I2cRawWaitAck(TRUE) == sys_status_success) &&
(I2cRawWriteByte(register_value) == sys_status_success) &&
(I2cRawWaitAck(TRUE) == sys_status_success) &&
(I2cRawStop(TRUE) == sys_status_success));
I2cRawComplete(1 * MILLISECOND);
I2cRawTerminate();
**************************************************************************************
Do I have to have a 450us delay between each I2CRaw command? If so, how do I implement this?
See Bosch Sensortec MEMS accelerometer sensor driver https://github.com/BoschSensortec/BMA2x2_driver source code
Hi all,
I found the problem finally. Its actually not a software problem and has nothing to do with the 450us delay.
I had configured the i2c with strong pull up
/* Configure the I2C controller */
I2cInit(I2C_RESERVED_PIO,
I2C_RESERVED_PIO,
I2C_POWER_PIO_UNDEFINED,
pio_i2c_pull_mode_strong_pull_up);
I had connected external i2c pull up resistors to my circuit. When i2c is released, the PIO is set to strong pull down. I think this cause current to flow through the external i2c pull up resistors hence consuming current.
Everything works fine now after I removed the external pull up resistors.
Hope it helps someone with the same problem in the future.