AnsweredAssumed Answered

How to use I2C Component

Question asked by adegonge on Jun 18, 2015
Latest reply on May 31, 2016 by Alice_Yang


I apologize for yet another noobish question. I'm trying to use the I2C component in Kinetis to interface with a sensor, however I'm having a bit of trouble understanding how the blocks work. I tried using the example code from the "help on component" but I think I'm missing quite a bit in order to make the program function.


What I want to do is first set the 7bit address, then issue a 16bit command to start measuring data, then I would like to receive that data (3 bytes) and store it in an array, and send the acknowledges after each byte if the component doesn't do that automatically. I don't need to write to the device, other than setting the address and issuing the commands. I'm sure this is actually a simple process but I'm very lost.


Side note - I do have the two devices set up properly with a pull-up resistor on the SDA and SCL lines, so that should all be set up properly. I'm just confused on how to use these blocks to get the data I want.





Update - I have been able to confirm transmitting data to the slave and also I am receiving data, however I keep only getting the values 5, 87, and 158 repeatedly. The first 2 bytes are meant to be the data and the third is the CRC, but I'm not seeing any fluctuation on those first 2 bytes no matter what I do.


I believe my problem is that the mastersendblock only sends a 7 bit value and automatically puts the 0 at the end to designate write. This probably affects my efforts to send the two command bytes following this command. Same likely goes with masterreceiveblock.