I2C example for F28335
Submitted by elgink on Fri, 06/28/2013 - 00:41
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
Answers
-
Submitted by elgink on Wed, 07/03/2013 - 23:21.
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.
0 -
Submitted by Anders89 on Fri, 07/05/2013 - 01:02.
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.
0 -
Submitted by elgink on Tue, 07/16/2013 - 00:27.
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!
0 -
Submitted by Anders89 on Fri, 07/19/2013 - 01:40.
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.
0