I2C example for F28335

I am trying to communicate with an i2c device using eepromReadWriteF28335 as reference. However, I am not sure the external references and state transitions are necessary. I want to run a basic test: Send one byte to the slave device (requesting the value of a certain register) and read the return byte. Can you provide a simple example?

Thanks! Kevin

peripheral explorer i2c TMP101

Let me revise my previous post: There is an external i2c temperature sensor (TMP101) on the F28335 Peripheral Explorer board that I want to configure and then read the temperature from. Attached is the working Lab 12-4 solution .c file and the chapter 12 pdf from the learning CD that accompanied the board. I would like to implement this .c file in vissim; however, I need guidance on how to set up the state transitions to accomplish the initialization and then read the temperature bytes.

Please provide any information you can about how to configure i2c in VisSim.

Hi Kevin,The attached

Hi Kevin, The attached diagram should do it. Note that we don't have a peripheral explorer to test against, but this should give you the idea.

Thanks for the diagram. I

Thanks for the diagram. I still have a problem with the Temp 101 Config block execution using the built-in firstpass variable as a trigger. For debugging purposes I set up another mcu to print what it is receiving via the i2c bus (as slave) on the serial port (I changed the config bytes to some obvious ascii chars). Through some reading and debugging I find that the built-in firstpass variable will only give one pulse at the start of the sim and that pulseTrain causes an enabled execution compound to execute one block in the compound per pulse. So in your diagram the firstpass could not get to the startTransmit block. If I do a step input into the Config block it will continue sending the config commands over and over again. Is there a way to run the block once (with a small delay) and break out of it? Thanks!

I see the problem. $firstPass

I see the problem. $firstPass is calling the config block before the I2C is setup. To delay config till after I2C setup, use a "one shot" block from Diagrams > Toolbox > Fixed-point > OneShot as in the attached.