AnsweredAssumed Answered

Using I2C with CMSIS

Question asked by Onur Demirel on Jun 4, 2018
Latest reply on Jun 5, 2018 by Onur Demirel

Hello,

 

I am learning about CMSIS functions and started with I2C application. I have some issues that I couldn't overcome. I stucked at the beginning. 

 

I am using TWR-KE18F board with MCUXpresso IDE and SDK2.0. I am trying to reach the WhoAmI register of onboard accelerometer.

 

my piece of example code is:

 

 

EXAMPLE_I2C_MASTER.Initialize(lpi2c_master_callback);
EXAMPLE_I2C_MASTER.PowerControl(ARM_POWER_FULL);
EXAMPLE_I2C_MASTER.Control(ARM_I2C_BUS_SPEED,ARM_I2C_BUS_SPEED_STANDARD);

g_master_txBuff[0] = 0x0D;      //WhoAmI register = 0x0D
EXAMPLE_I2C_MASTER.MasterTransmit(SLAVE_ADR,g_master_txBuff,1,true);

while(!ARM_I2C_EVENT_TRANSFER_DONE)
{}
while(EXAMPLE_I2C_MASTER.GetStatus().busy)
{}

EXAMPLE_I2C_MASTER.MasterReceive(SLAVE_ADR,g_master_rxBuff,1,false);

PRINTF("0x%2x", g_master_rxBuff[0]);

 

and I see 0xff.

 

As I said I am new to this topic and any help will be appreciated. 

 

Thanks,

 

Onur

Outcomes