I2C (advanced) Read Issue

Discussion to talk about software related topics only.
Post Reply
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

I2C (advanced) Read Issue

Post by Mark »

Hello,

In searching through this forum I found a reference to the advanced I2C functions having an issue with the I2CRead, specifically that the first read did not return correctly and that an I2C_SET_NO_ACK had to be issued after the first I2CRead and then another I2CRead to obtain the correct value. This was stated to be fixed but still looks to be broken. Will there be a proper fix to I2CRead?
IMG_4736.JPG
IMG_4736.JPG (1017.24 KiB) Viewed 11895 times
Thanks,
Mark
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: I2C (advanced) Read Issue

Post by TomNB »

Hi Mark. Can you send a link to the post you are referring to?
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

Code: Select all

{
	int iRtn;

	BYTE address = 0x22;		//mpc23008 address, U13
	BYTE addr_gpio = 0x09;		//gpio register address
	BYTE data_gpio = 0;			//variable to hold gpio read

	iRtn = I2CStart(address, I2C_START_WRITE, I2C_START_TIMEOUT);
	iprintf( "I2CStart = %d\r\n>", iRtn );

	iRtn = I2CSend(addr_gpio, I2C_RX_TX_TIMEOUT);
	iprintf( "I2CSend = %d,I2CRtn=  %d\r\n>", addr_gpio, iRtn );

	iRtn = I2CRestart(address, I2C_START_READ);
	iprintf( "I2CRestart = %d\r\n>", iRtn );

	iRtn = I2CRead(&data_gpio, I2C_RX_TX_TIMEOUT);
	iprintf( "I2CRead = %d,I2CRtn=  %d\r\n>", data_gpio, iRtn );
    iprintf("LED Value= %X\r\n>", data_gpio);

    //This is an issue that was supposed to be resolved (see NB forum and i2cmaster.h description)
	I2C_SET_NO_ACK;

	iRtn = I2CRead(&data_gpio, I2C_RX_TX_TIMEOUT);
	iprintf( "I2CRead = %d,I2CRtn=  %d\r\n>", data_gpio, iRtn );
    iprintf("LED Value= %X\r\n>", data_gpio);

	iRtn = I2CStop();
	printf( "I2CStop = %x\r\n>", iRtn );

	return data_gpio;
}
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: I2C (advanced) Read Issue

Post by TomNB »

Thanks Mark, but what I was really looking for was just a link to the thread so we can read the details.
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

I gave the link!
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: I2C (advanced) Read Issue

Post by TomNB »

Sorry, I scrolled to the last entry and saw your code post. Didn't realize you made two separate ones. What release are you using?
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

Release 2.7.5
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

BTW, the code snippet that I provided is my code that will help demonstrate the issue. If the remove the I2C_SET_NO_ACK along with the second read you will see that the first read provides incorrect data.
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: I2C (advanced) Read Issue

Post by Mark »

Any updates on this issue? Has it been verified/corrected?
Post Reply