I have been agonizing over this simple I2C application for quite some time now and I could really use some help. I have been following this guide for sometime: Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse
I am attempting to use I2C to communicate with the magnetometer side of an LSM303DLHC on the 9DOF from Adafruit.
The board has resistors on the breakout so that isn't my issue.
My SDA and SCL lines are hooked up properly.
The I2C frequency is set just fine according to the workaround for the silicon error listed in the errata.
My device library and my PEimplementation are communicated between the generated code and everything else just fine.
One issue I'm getting is that for some reason, the I2C1_S register will have the busy flag set.
The general flow of things for reading the data registers on the magnetometer is as follows: "SimpleHeading()" -> "getMagX" -> "LSM303_ReadReg" -> "CI2C1_MasterSendBlock" which will send the device address and the register address without a stop bit. I will then call "CI2C1_MasterReceiveBlock" with a stop bit so that I'll be getting data back from the register and then ending the communication. Btu for some reason the code generated by PE things that the bus is busy all the time.
I'm not sure exactly why this is happening but I can't fix it the code. I have attached my project in an archive file.
If somebody could look at it, I would greatly appreciate it. I am literally on the edge of having a complete mental breakdown because of this thing.
Original Attachment has been moved to: I2C_PE.zip