Page 1 of 1

MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Mon Apr 27, 2020 11:36 am
by rob18767
I am using a MOD5270 on a board with an ISL12026 RTC connected to the I2C bus.

After I2CInit then execute the following code.

Code: Select all

uint8_t data[4];

	int ret;

	if( I2CStart( 0x6F, I2C_START_WRITE) < I2C_TIMEOUT )
		 iprintf("We have a %X on the bus write\r\n", 0x6f );
	else
	{
		iprintf("Fail start write 1\r\n");
		return;
	}

	data[0] = 0x00;
	data[1] = 0x3F;
	data[2] = 0x2;

	ret = I2CSendBuf(0x6f,data,3);

	iprintf("Write 1 returned %d\r\n", ret);

	I2CStop();
What I see on the UART is
We have a 6F on the bus write
Write 1 returned 4
So it appears that as 4 returned from I2CSendBuf is a I2C_TIMEOUT.

So while the I2C Start appears to be good I am timing out of the I2CSendBuf.

Any ideas?

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Tue Apr 28, 2020 3:43 am
by pbreed
Try stealing the I2CScan function from the exmaple

nburn\examples\standardsatack\I2C\EthernetToI2C.

This will tell you if the hardware is hooked up correctly, lines, pull ups, pin initalization etc....

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Tue Apr 28, 2020 5:29 am
by rob18767
I got to the StandardStack directory and there is no I2C directory.

In order to potentially save time I did do this.

Code: Select all

 for( int x =0; x<128; x++)
 {
 I2CInit();
 if( I2CStart( x, I2C_START_READ ) < I2C_TIMEOUT )
 iprintf("We have a %X on the bus\r\n", x );
 I2CStop();
 }
To which I received back:
We have a 57 on the bus
We have a 6F on the bus
I changed the code as follows to takes out the starts and stops

Code: Select all

uint8_t data[4];

	int ret;



	data[0] = 0x00;
	data[1] = 0x3F;
	data[2] = 0x2;

	ret = I2CSendBuf(0x6f,data,3);

	iprintf("Write 1 returned %d\r\n", ret);



	data[0] = 0x00;
	data[1] = 0x3F;
	data[2] = 0x6;

	ret = I2CSendBuf(0x6f,data,3);

	iprintf("Write 2 returned %d\r\n", ret);
	
	data[0] = 0x00;
	data[1] = 0x3f;

	ret = I2CSendBuf(0x6f,data,2);

	iprintf("Write 3 returned %d\r\n", ret);



		ret = I2CReadBuf(0x6f,data,1);

		iprintf("Read returned %d\r\n", ret);

		 iprintf("buffer %X\r\n", data[0] );
	
	
To which I got:
Write 1 returned 0
Write 2 returned 0
Write 3returned 0
Read returned 2
buffer 81
The writes look good.

So I guess my only question is why is the I2CReadBuf returning 2 (I2C_NEXT_READ_OK)?

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Tue Apr 28, 2020 8:29 am
by TomNB
From your part data sheet:

Reading the Real Time Clock
The RTC is read by initiating a Read command and specifying the address corresponding to the register of the Real Time Clock. The RTC Registers can then be read in a Sequential Read Mode.

So it looks to me like its ready to send the next register value

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Tue Apr 28, 2020 11:18 am
by rob18767
Ah okay. Thank you Tom.

Another question. I am confused.

With the ISL12026 work with the Netburner runtime i2c libraries on the MOD5270?

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Tue Apr 28, 2020 1:38 pm
by TomNB
I'm not sure which ones you are referring to. You already are using the i2c libs in your function calls, correct?

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Wed Apr 29, 2020 6:13 am
by rob18767
I should have clarified. We have two different PCBs to which MOD5270s are attached.

I was given charge of maintaining the software for one PCB. It was pointed out to me that on the board I was maintaining the software for that the RTC could not be set.

The board has an ISL12026 connected to the I2C lines of the Netburner.

Reading the Netburner Runtime Libraries Reference manual I see for section 17. RTC Library.
The RTC (real-time clock) library allows users to set and read the real-time clock manually, or use the current system time to set the RTC time or use the current RTC time to set the system time. The RTC is external to the core module and is located on the MOD-DEV-40, -70, and -100 development boards. While the system time inside a core module can be lost when it loses power or is reset, the RTC is sustained by a supercapacitor which is also located on the development boards. This library acts as an interface between the system and RTC time clocks.

Header File

#include <rtc.h> // Found in \Nburn\<HardwarePlatform>\include
We have MOD-DEV-70s that come with MOD5270 that has a PCF8563 RTC (same as MOD-DEV-100)

However I see the MOD-DEV-40 comes with an X1226S8 RTC.

This seems to be an obsolete version of the ISL12026.

Therefore I take it that the rtc.h library can work with either the PCF8563 or the ISL12026 rtc's?

Interchangeable through address detection?

Re: MOD5270 I2C Problem with ISL12026 RTC and I2C timeouts

Posted: Wed Apr 29, 2020 9:53 am
by rob18767
The answer to my question is yes the ISL12026 RTC will work with the rtc.h netburner library.

*edit - Albeit unreliably. Sometimes the RTCSetTime works and sometimes it does not.