Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C external responds to multiple addresses #4

Open
rstoica opened this issue Nov 2, 2017 · 1 comment
Open

I2C external responds to multiple addresses #4

rstoica opened this issue Nov 2, 2017 · 1 comment

Comments

@rstoica
Copy link

rstoica commented Nov 2, 2017

Hi,

First of all thanks for sharing this nice project with the open-source community! Your work is great!

One thing I have noticed by trying out your code for the external I2C communication is that it responds to other addresses except the one selected by firmware and the 0x00 address for the general call. As I understand from your code this is not the desired behavior as you would like to have the device answer to its own fixed address, say 0x51.

I know the PIC32 MCU used needs to explicitly be told to lock only onto the given address and ignore the other calls on going on the bus and this is what is done here (app_i2c_external.c#L106)

     PLIB_I2C_ReservedAddressProtectEnable(I2C_EXTERNAL);

However, as a higher degree of selectivity the PIC32 has also a mask for addressing which runs on top of the selected address. The call to (app_i2c_external.c#L112)

    PLIB_I2C_SlaveMask7BitSet (I2C_EXTERNAL, 0xFF);

acts as a wildcard and actually makes the MCU respond as a slave to almost all the addresses on the bus (i.e. except the protected ones on I2C 0x01-0x08).

As a fix to achieve your desired behavior you should explicitly set

    PLIB_I2C_SlaveMask7BitSet (I2C_EXTERNAL, 0x00);

and in this way only the desired address will be replied to (e.g. 0x51), and respectively, 0x00 as the general call address.

This behaviour is documented in section 24 of the MCU detailed datasheet

@soldernerd
Copy link
Owner

soldernerd commented Nov 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants