lpcware

LPC11U67 I2C ROM Driver Bug?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Belias on Wed Jun 25 05:01:59 MST 2014
I am porting an CMSIS project (previously running on LPC1115) to LPCOpen, because the LPC11U67 is not supported in CMSIS.

But currently the ROM API gives me some headaches.

I dont know if this problem is directly connected to the ROM API Problem but:

I have a test loop, which does the following:
for (i = 0; i < 1000; ++i) {
if (sensorReadByte(MMA8451_ADDR, ACC_WHO_AM_I) != 0x1A) {
printf("Acc WhoAmI Register incorrect %d\n", i);
} else {
printf("Acc WhoAmI Register correct %d\n", i);
}
}


sensorReadByte calls the ROM API for I2C. With very strange effects. The variable i stays 0 all the time (and the code is stuck in the loop forever). After some investigation i found, that the compiler places i inside register r4. But when the I2C Rom API gets called, r4 gets reset to 0 (after it is indeed incremented by one).

If i comment out the call of the I2C ROM API, everything is fine, and the loop runs as expected, so the ROM API call to LPC_I2CD_API->i2c_master_tx_rx_intr(i2cHandleMaster, &param,
&result);
screws R4, which should not be the case.

Is this a bug in the ROM API? AFAIK R4 (and above) must be preseved by the method that gets called.

Any Ideas? Thanks! :)

Outcomes