Author Topic: SBC68EC IO5RE - I2C Interfacing Issues w/ DS1307 RTC and onboard 24LC256 EEPROM  (Read 3774 times)

dmiles813

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
This question was posed to Modtronix staff, and promptly answered....  I was asked to post this to the forum for others who may encounter the same issue...

I have the IOR5E and an SBC68EC.  I have been working on it a few months now.

I just developed the necessary code for configuring the RTC (DS1307 from you) via the I2C bus.  I ran into a little glitch however.  In order to communicate with the DS1307, I needed to run the I2C bus at 100KHz instead of 400KHz.

So I closed the I2C bus, reconfigured for 100Khz, performed the read or write to the DS1307 RTC, then closed the I2C bus again.  To my surprise, I would then trip the watchdog when accessing a web page.  I soon discovered your code does a single open upon initialization expecting that the I2C bus would not be closed.

I am digging through the FileSystem handler code and am not coming up with an easy solution to re-open the bus when needed.  Can you think of any way of handling re-opening the I2C bus which would be fairly easy to implement?  For obvious reasons, I do not want to deviate from your supplied code too much.

I was also thinking of backing the I2C bus down to 100KHz, and avoiding opening/closing the bus, but I am unsure of the potential performance issues this would cause in a coop-mt'ing environment.

I am just looking for your general input....before digging deeper.  I am thus far impressed with your teams code.

Thanks Again,

-D. Miles


----------  THE ANSWER  -----------

I think whenever you use the I2C bus, you should leave it in the condition you found it in when
done. Seeing that the stack code always expects it to be open at 400khz, you have to restore it to
this condition. You can do this by opening it for use by the external EEPROM again with this call:

//Initialize the EEPROM access routines. Use ~ 400 Khz.
XEEInit(EE_BAUD(CLOCK_FREQ, 400000));

You will have to place this include in the file you issue this call from:
#include "net\xeeprom.h"