How to use i2c?!?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
CSM2711
Posts: 47
Joined: Mon Apr 16, 2018 10:28 am
Location: Germany
Has thanked: 1 time
Been thanked: 9 times
Contact:

How to use i2c?!?

Post by CSM2711 »

Hello,

I'm already trying a long time to implement a project with i2c and flowcode 6.

A short description:
I would like to communicate with a PC16F1827 i2c with a sensor chip, for this is necessary from my following steps.
1. Initialize and operate the I2C interface on the controller.
I think here is an i2c master needed?
2. Simulate the sensor chip and generate the corresponding answer when receiving the messages and send it back
I think here is needed a cal i2c?

Do I really need this two components?
Why can not I get a console window on the i2c master?
how do i connect the i2c master and the i2c cal?
Does any one has an simple (or realy simple) example for use i2c with another (not included in flowcode) device?


thanks a lot.
Marcel

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to use i2c?!?

Post by Benj »

Hello Marcel,

If you haven't already then it's worth reading this blog post for a better insight into I2C and how to use it.
https://www.matrixtsl.com/blog/simplifi ... c-and-spi/

Let us know how you get on.

CSM2711
Posts: 47
Joined: Mon Apr 16, 2018 10:28 am
Location: Germany
Has thanked: 1 time
Been thanked: 9 times
Contact:

Re: How to use i2c?!?

Post by CSM2711 »

First of many thanks, but the blog had already readed.
My main problem right now is that I do not understand how the external device (i2c) is simulated.
Is an I2C cal needed here, an injector or does a completely separate component have to be created?

Or is there another way to do this?
To make my request a little clearer here is my code.
Attachments
i2c.jpg
i2c.jpg (35.55 KiB) Viewed 3963 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to use i2c?!?

Post by Benj »

Hello,

There are two ways to simulate a reply from an I2C device.

The first is to use the I2C master component as you have done and to make an injector component that will reply like the real world I2C device would. This is not very straight forward but is possible and I have created a wiki page on how you might go about this.

https://www.matrixtsl.com/wikiv6/index. ... a_Injector

The second option is to create your own component using the I2C CAL component. You can then add code to drive the I2C communications and provide simulation macros to override the embedded functionality when the component is used, this method won't necessarily test the communications but provides a slightly better out of the box user experience so you don't have to mess about with injectors.

https://www.matrixtsl.com/wikiv6/index. ... eled_robot

In v8 we have taken steps to ensure that the injector components are better supported and that the CAL components are much easier to build on so both options are still viable.

If you have a go then let us know how you get on and if you get stuck then post what you have so far and we can help you to continue.

CSM2711
Posts: 47
Joined: Mon Apr 16, 2018 10:28 am
Location: Germany
Has thanked: 1 time
Been thanked: 9 times
Contact:

Re: How to use i2c?!?

Post by CSM2711 »

Thanks a lot, it works with the file injector.
But my next problem is i'm not able to display the i2C (or any other) output data to the scope monitor.
attached you will find the project my you can see whats going wrong.....

Marcel
Attachments
PCAP.fcfx
(13.08 KiB) Downloaded 291 times

Post Reply