Bug in PE 5.2.0: i2c bus and DS1307/24LC256

GreenLeader

Senior Member
I suspect there may be a bug in v5.2.0 compared to v5.1.7. The simulator seems to be ignoring the slave address for hi2c commands.

My code seems to work on 5.1.7 but I get a message "The simulated RTC does not use word mode i2cword" when I run in 5.2.0.

I have the checkboxes for simulated 24LC256 and DS1307 selected and I am using a 40X1.

I set up the RTC and 24LC256 like this:
Code:
#PICAXE 40X1
' Setup i2c for RTC and 24LC256 EEPROMS
hi2csetup i2cmaster,%11010000,i2cslow,i2cbyte 'DS1307 RTC
hi2csetup i2cmaster,%10100000,i2cfast,i2cword 'EEPROM addr 0
 
hi2cin [%11010000],0,(b8,b9,b10,b11,b12,b13,b14,b15)
The attempt to read the clock with hi2cin fails.
However, if I comment out the 2nd hi2csetup command (ie for the EEPROM) then the code runs....
 

Technical

Technical Support
Staff member
Your program is incorrect, not the software.

You cannot use two hi2csetup commands like this with the PICAXE system. The i2c bus can only be in byte address mode or word address mode, it cannot be in both modes at the same time!

To achieve what you want to do you must use the hi2csetup command, talk to the DS1307, then use another hi2csetup command, talk to the EEPROM etc.

ie the hi2csetup command must go between each chip use, to change the mode between word and byte addressing.
 

GreenLeader

Senior Member
OK thanks for pointing that out .. so the bug is my code then :)
Its a moot point, but why does 5.2.0 object and 5.1.7 does not?
 
Top