writei2c - use of location value

ValueAdd

Senior Member
I seek some clarification on using the writei2c and readi2c commands.

The format is:
writei2c location, (variable)
or
writei2c (variable)

The question is, when I do not include a value for location as in the second format above, does the PICAXE
- use (and write) a value of 0 for the location?
or
- not transmit any location data to the slave device as set in the slavei2c command.
 

kranenborg

Senior Member
It is the latter option, since some simpler i2c devices do not have any internal registers at all and do not expect such an internal address (i.e. "internal device location", sometimes also called command). For example you could take a look at the datasheet of the PCF8574A i/O controller where the i2c write sequence is explained; you will see that after the i2c device address byte there is no address/location byte but instead one or more databytes for setting the I/O pins. Very early implementations of the PICAXE-18X/28X/40X had the limitation in the i2c protocol that a location byte or word was always necessary, but this is now a very long time ago and all i2c devices no matter how complicated are properly supported.

/Jurjen
 
Last edited:

ValueAdd

Senior Member
Thank you Jurjen

That is what I was hoping, but did not see it as being 100% clear what happens from the manual
 
Top