Anonym

Active member
Hullo!

Reading the manual "Using I2C with PICAXE", I found out that I need an I2C address to use a I2C slave device. In the datasheet of my I2C device (https://bit.ly/2SLEZdP), it sais the default I2C address is 0X27, however the picaxe I2C manual wants me to use an address in the form %10100000. Can I use 0X27? Or do I need to convert it to the binary form somehow, and if that is the case, then how?

Thank you!

inglewoodpete

Senior Member
Hullo!

Reading the manual "Using I2C with PICAXE", I found out that I need an I2C address to use a I2C slave device. In the datasheet of my I2C device (https://bit.ly/2SLEZdP), it sais the default I2C address is 0X27, however the picaxe I2C manual wants me to use an address in the form %10100000. Can I use 0X27? Or do I need to convert it to the binary form somehow, and if that is the case, then how?

Thank you!
Syntax requirements for the PICAXE programming environment require us to use '\$' rather than '0x' as a prefix to indicate hexadecimal values.

0x27 means hexadecimal value \$27 (39 decimal or %00100111 in binary). However, if you read the command description for hi2cSetUp, you will see that you need to shift the value upwards (left) by 1 binary bit (or multiply it by 2). So you will need to use the value \$4E (78 decimal or %01001110).

Anonym

Active member
Syntax requirements for the PICAXE programming environment require us to use '\$' rather than '0x' as a prefix to indicate hexadecimal values.

0x27 means hexadecimal value \$27 (39 decimal or %00100111 in binary). However, if you read the command description for hi2cSetUp, you will see that you need to shift the value upwards (left) by 1 binary bit (or multiply it by 2). So you will need to use the value \$4E (78 decimal or %01001110).
Thank you very much, this really helps a lot! However, I was planning to use the i2cslave and writei2c commands. Is the procedure different for those?

inglewoodpete

Senior Member
I suspect you are trying to drive an i2c interface to an LCD. If so, you will probably find this thread helpful.

inglewoodpete

Senior Member
Thank you very much, this really helps a lot! However, I was planning to use the i2cslave and writei2c commands. Is the procedure different for those?
i2cslave and writei2c are very old bit-bang commands. It would be better to update to hi2cSetUp and hi2cOut commands.

Aries

New Member
Actually, Picaxe Basic does accept the "0x" prefix to indicate hexadecimal format (as I found out after I had converted all my prefixes to \$)

Speddo

New Member
Hi.
I have had a learning curve with the PicAxe and i2c to LCD via a serial backpac on the LCD.
The slave Address may be \$27 or %00100111 , but the hi2cmaster command requires the slave address to terminate in a "command" bit, so the address becomes %011001110, or a 7 bit slave address + "command" bit of 0, which means "Write to slave", a command bit of 1 means read from slave.

lbenson

Senior Member
%00100111 . . . %011001110
Hope it's just a posting typo, but %00100111 would be shifted to %01001110.