MOD5270, I2C and latest software problem

Discussion to talk about software related topics only.
Post Reply
GreatBigGiantBrain
Posts: 3
Joined: Tue May 10, 2011 5:04 am

MOD5270, I2C and latest software problem

Post by GreatBigGiantBrain »

We have the MOD5270. Our old NetBurner software is from around2009ish... I've formatted my computer since then, so I do not have it. We bought the latest software, and I ported the source code into a new project. The OLD .s19 program reads the I2C values correctly. The exact same source code compiled on the new NetBurner SDK has all sorts of problems reading the I2C values.

With the old .s19, everything seems to work as it should, so I can only assume something has changed in the new SDK that has broken my code. Is there anything new I have to do in the new SDK (2.5.2) to make I2C read correctly?

Some observations:
With both the send and read, when you power cycle the device, you get two good reads, then an I2C_TIMEOUT (4).
With only the send, if the device had I2C_TIMEOUTS before (not power cycled) and it is programmed, I get more I2C_TIMEOUTS.
With only the send, and you power cycle the device, you always get I2C_OK back.

Here's a simplified version of what I am trying to do (I'm using I2CMaster):

Code: Select all

    I2CInit();
    while(1)
    {
    	BYTE command = 0x88;
    	BYTE buffer = '\0';
    	I2CStat = I2CSendBuf(0x28, &command, 1, true);
    	Log("S:%X\r\n", I2CStat);
    	I2CStat = I2CReadBuf(0x28, &buffer, 1, true);
    	Log("R:%X\r\n", I2CStat);
		unsigned short test = (&buffer)[0];
		endian_swap(test);
		Log("%i\r\n", test);

    	OSTimeDly(10);
    }
And some output from this:

Code: Select all

S:0  <-- Send result
R:2  <-- Read Result
1536 <-- read value
S:0
R:2
768
S:4
R:4
0
S:4
R:4
0
Thanks,
Brian
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: MOD5270, I2C and latest software problem

Post by lgitlitz »

Hi,

The I2CReadBuf function should not be returning "I2C_NEXT_READ_OK" unless you have the stop parameter set to false. It is hard to tell exactly why this is happening without seeing the data sheet for the slave device. What is the device you are communicating with? Does the device want you to send an I2C restart on the bus before the read, many devices work this way? Another possibility is that some performance enhancements in the NNDK has made your code run faster, which now may violate a delay between transactions spec of your I2C slave. Try putting in an OSTimeDly(2) between the send and receive calls.

With your software renewal you also get a full year of NetBurner support and you may want to submit a ticket there. Engineers at NetBurner, such as myself, try to stay active on this forum but we must give priority to the official support system and other ongoing projects here.

-Larry
GreatBigGiantBrain
Posts: 3
Joined: Tue May 10, 2011 5:04 am

Re: MOD5270, I2C and latest software problem

Post by GreatBigGiantBrain »

Thanks for the reply. I will open a support ticket.

I tried a Restart, and while I did not get errors, I never got valid voltages from the chip. The ReadBuf seems to always return I2C_NEXT_READ_OK for the first two power-cycle reads, then I2C_TIMEOUT after that.

The chip is the "Maxim Max127/Max128 Multirange, +5V, 12-Bit DAS with 2-Wire Serial Interface"
http://www.maxim-ic.com/datasheet/index.mvp/id/1890

thanks,
Brian
greengene
Posts: 164
Joined: Wed May 14, 2008 11:20 am
Location: Lakeside, CA

Re: MOD5270, I2C and latest software problem

Post by greengene »

your device provides two bytes of data.
so make your buffer at least 2 bytes long and read
2 bytes.
GreatBigGiantBrain
Posts: 3
Joined: Tue May 10, 2011 5:04 am

Re: MOD5270, I2C and latest software problem

Post by GreatBigGiantBrain »

I ended up having to backtrack to Netburner SKD 2.3. That and your advice of reading 2 bytes is what seemed to work for now.

Reading 2 bytes helped. I stopped getting any errors after that (and going back to 2.3, from 2.5.2... 2.5.2 wouldn't work regardless of what I tried)

Thanks for all your help, I am set for now until I want to upgrade to 2.5.2, then I'll have to figure it out.

Brian
Post Reply