On 2013-03-31 5:07 AM, veegee wrote: > Hi all, >=20 > I'm testing the I2C functionality on the PIC32MX220F032B with the > i2cdetect program on a Raspberry Pi. i2cdetect simply prints out a table > of all found addresses on an I2C bus. The slave address of my PIC is 0x42= .. >=20 > For some reason, if I configure the I2C module on the PIC *without* the > I2C_USE_RESERVED_ADDRESSES flag to I2CSetSlaveAddress, i2cdetect shows th= is: >=20 > Note that the meaning of I2C_USE_RESERVED_ADDRESSES according to the > Microchip PIC32 I2C library is: "Disable reserved address protection, > allowing responses to reserved addresses (violates I2C specification) ". >=20 > # i2cdetect -y 0 >=20 > 0 1 2 3 4 5 6 7 8 9 a b c d e f > 00: 03 04 05 06 07 -- -- -- -- -- -- -- -- > 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 40: -- -- 42 -- -- -- -- -- -- -- -- -- -- -- -- -- > 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 70: -- -- -- -- -- -- -- -- >=20 > Note the unexpected 0x03, 0x04, 0x05, 0x06, and 0x07 addresses being > detected. >=20 >=20 > But if I *do* pass the I2C_USE_RESERVED_ADDRESSES flag like so: >=20 > I2CSetSlaveAddress( > I2C1, 0x42, 0, > I2C_USE_7BIT_ADDRESS | I2C_USE_RESERVED_ADDRESSES > ); >=20 > i2cdetect shows what I expect: >=20 > # i2cdetect -y 0 >=20 > 0 1 2 3 4 5 6 7 8 9 a b c d e f > 00: -- -- -- -- -- -- -- -- -- -- -- -- -- > 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 40: -- -- 42 -- -- -- -- -- -- -- -- -- -- -- -- -- > 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 70: -- -- -- -- -- -- -- -- >=20 >=20 > When I tested the same functionality on a PIC18F26K22, the behaviour was > as expected, with only 0x42 showing up without any special reserved > address use configuration flags. But for the PIC32, the behaviour seems > to be the opposite of what I expect. >=20 > Can anyone shed some light on this? >=20 I figured it out. There's yet another bug in Microchip's disgustingly messy and poorly implemented peripheral library. I2C_USE_RESERVED_ADDRESSES is a macro for 0x800, which corresponds to a logic 1 at bit 11 of the I2CxCON register. When set, strict reserved addressing is enforced and the device does not respond to reserved address space. Their library has it backwards. --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .