i2c timeout issue with X1226 rtc's

Discussion to talk about software related topics only.
Post Reply
mmk-tsm
Posts: 33
Joined: Mon Jan 05, 2009 9:22 am

i2c timeout issue with X1226 rtc's

Post by mmk-tsm »

Hello All,
I sent this as a ticket to Netburner, but perhaps someone might have some ideas:

We are still using X1226 rtc's, and also using old Netburner i2c code
to read from it. We modified the original code to use a PIT timer to
escape from timeouts. And we are currently experiencing occasional
timeouts - we generate an alarm if the i2c timeout occurs. We have set
the i2c timeout time to 20ms. - see below for example.

Questions:
1. Have there been any modifications to the i2c code - our version
would date back several years, to devC latest software at least.
2. Are you aware of any problems with X1226 chips? We know they
have become obsoleted.

Example of i2c function:
you can see where we replaced original OSTimeDly(1).

int I2CSend( BYTE val, DWORD nPITs_to_wait )
{
sim.i2c.dr = val;
g_nI2CWaitPits = nPITs_to_wait; // value decremented by PIT.
while ( ( sim.i2c.sr & 0x2 ) == 0 )
{
//mmk OSTimeDly( 1 );
//mmk nPITs_to_wait--;
//mmk if ( nPITs_to_wait == 0 )
if( g_nI2CWaitPits == 0 ) //decremented by PIT timer interrupt
{
return I2C_FAIL;
}
}
sim.i2c.sr = 0x0;
return I2C_OK;
}
Post Reply