I2C problem bit rbf

Thread Starter


Joined Dec 24, 2015
i'm new using pic32 and i'm doing my first project with it. I'm using pic32mx320F128H as a master and a HMC5883L as a slave. Problem is when i try to read the values from the HMC5883 the bit I2C1STATbits.RBF is always 0(i made my own i2c fucntion so to find the error i just used printf ), Is it possible that the slave isnt well connected to the micro controller? i'm using ports RG2 and RG3 for SCL and SDA as it is said in the chipkituno32 datasheet, and a 4k7 pull-up resistor.

thanks in advance


Joined Apr 24, 2011
Checking if the slave and master communicate is simple if you have an oscilloscope just see if the 9th ACK bit is low. If you don't have a scope...

I2C has no lower speed limit, so you can clock out address bits one at a time and watch them on a volt meter, or even a LED. When you get to the ACK bit you can see if the slave sees what the master sends, if the address is correct, and the slave is ready to start responding.

I2C can be tricky to set up as it seems every slave interprets the standard it's own way, but you do get lots of devices connected thru a simple connection. It is my preferred way to go.