Page 1 of 1

Simple i2C - Single Byte read and Write

Posted: Thu Jul 06, 2017 1:30 pm
by Jay Dee
Hi, I am working with another obscure i2C based chip and made up some generic i2C macros, others may find these helpful, especially if your are new to i2C.

I know there are loads of examples and you can instead use the ReceiveTransaction and Send transaction macros but I have traditionally done it using the discrete i2C macros.

They Only send a single data byte or read a single data byte.
But if, like me, your working on a new chip and want to quickly read/write some test bytes using i2C, this might be a good starting point.
I based it on a ECIO40P, and used B4=Data, B3=Clock. but target chip can be anything, you choose.
Generic_i2C_Test_ECIO.fcfx
Generic i2C macros
(15.36 KiB) Downloaded 436 times
J.

Re: Simple i2C - Single Byte read and Write

Posted: Sat Aug 26, 2017 12:25 am
by derfleznew
Thanks for the I2C example code. We have been having fits reliably reading I2C data from an MicroChip MCP9600 thermocouple chip. What we get is around 9 to 10 returns with missing bit 3, then a couple of good readings. Scoping this out shows strange behavior and we think the issue is with the FlowCode7 component. Very frustrating to troubleshoot.

Have you had any random bad readings from the chip you are using?

Re: Simple i2C - Single Byte read and Write

Posted: Tue Aug 29, 2017 4:04 pm
by Benj
Hello,

Have you seen the blog post here on I2C communications it explains the basics and how to read a device datasheet.
https://www.matrixtsl.com/blog/simplifi ... c-and-spi/
Have you had any random bad readings from the chip you are using?
No it sounds like something is potentially wrong here.

If the blog doesn't help then can you post your program so we can double check the I2C protocol is being followed correctly in your firmware.
Also what value of pull up resistor are you using?