Simulator problem - compiler too?

johndk

Senior Member
I'm playing with a new (for me) RTC chip. PCF85263A. It has some nice features, but mostly I need a 3v i2c RTC.

The slave address for this chip is %10100010 (A2h) which is where the problem comes in. The 24LC series of eeproms has a long established slave address of %10100000 (A0h). The RTC chip takes the 'I2CByte' parameter while the eeprom takes the 'I2CWord' parameter. The simulator forces the 'word' parameter for this address and will quit (with a warning) if 'byte' is used.

That's not too big a problem because one can easily fool the simulator. But since I'm having difficulty in accessing this RTC , I'm wondering if the compiler does something funky with this address as well?

My intention is to use both the eeprom and the RTC , and I'm hoping that the slave addresses will be compatible. But for testing purposes, I only have the RTC chip hooked up. No dice, so far. That could be me getting used to the interface which is a bit more complex than the tried and true DS1307. So just to rule this possibility out, can someone confirm for me that the 28x2 should be able to use this slave address with the 'byte' parameter?
 

hippy

Ex-Staff (retired)
The compilers can work with both I2CWORD and I2CBYTE address size parameters. The issue would seem to be simulation, or perhaps configuration for simulation. It is not possible to mix and match word and byte addressed I2C Eeproms during simulation but it should be possible to simulate one or the other, and you could perhaps configure the program so it can be simulated in full.
 

johndk

Senior Member
Okay. That's good news. The compiler doesn't care as long as you set up the right parameter for the particular slave. As for the simulator, I can work around that.

Now in terms of address, the PCF85263A looks like a eeprom with one of the chip select bits set. As long as I don't duplicate that address with an eeprom and I do a hi2csetup to set the 'word' or 'byte' parameter before addressing one or the other, I should be able to have both these chips on the same bus. At least, that's the plan.
 

hippy

Ex-Staff (retired)
That's right so this should read the first byte of word addressed I2C Eeprom, and then read the first byte of the PCF85263A ...

Code:
Hi2cSetup I2CMASTER, $A0, I2CSLOW, I2CWORD ; Read Eeprom at $A0
HI2cIn 0, (b0)
Hi2cSetup I2CMASTER, $A2, I2CSLOW, I2CBYTE ; Read RTC at $A2
HI2cIn 0, (b1)
Just do the right setup before whatever access and it should all just work.
 
Top