Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
I2C addressing (from posts by PCM and Ttelmah) |
Posted: Tue Apr 21, 2020 6:31 am |
|
|
CCS uses 8-bit i2c address format the 'address byte'
All their functions and #use statements expect 8-bit format.
7-bit I2C format is used by NXP.
To convert 7-bit format to 8-bit, simply left-shift the 7-bit format by 1.
Do not initialize a slave address to an odd number. It will not work.
Do not use decimal. Think and use hex for i2c addresses.
Do not use reserved i2c addresses for a slave.
The 'address byte', has a 7bit address as the top seven bits, then the
R/W bit as the bottom bit. The PIC uses it's addresses in this format.
On the slave hardware address recognition, only the upper seven bits
are used. So only even 'addresses'. When sending the address byte, you
need the same format, but with the R/W bit included.
The most useful 'tool' for working with I2C addressing is the bus scanner
program from PCM_Programmer at:
<http://www.ccsinfo.com/forum/viewtopic.php?t=49713> |
|