0

Hey guys i've been working on this like 72 hours straight and i can't find the error, i'm working on a PIC16F1719 i'm trying to set 3 peripherials an ADC a I2C Protocol and a USART for comunicating to a BT however the ADC was easy, but i'm having a rough time with the I2C despite the fact i've check the code several times, for some reason when i get the ACK's everything seems OK, but when i go for a lecture on the sensor (MPU6050) nothing shows up but the value i putted last time on the buffer, any ideas why this is happening? It's like the buffer doesn't clear itself and i think i can´t clear it through software, thanks.

Jens Gustedt
  • 76,821
  • 6
  • 102
  • 177
  • Does this have anything to do with programming, or is it a hardware question? – Carcigenicate Apr 15 '17 at 15:17
  • Well i think it goes for both same time, i got my hardware good set, i got the pull up resistors and everything, the main deal is about why the Buffer doesn´t shows the value from the sensor but the address i gave it, like everything got stacked there in the buffer so nothing really happens – Camilo Penagos Apr 15 '17 at 15:43

1 Answers1

0

i2c slave has the ability to lock the bus if the master does not communicate correctly with it (several possible scenarios...) This is electirically possible since the 2 wires are wired-and, that means if any slave pulls the clock (for example) down, and keeps it that way, the bus is locked.

  • Always check first the values on both wires (using scope or dvm), if '0' it means bus locked.
  • Next test the status register of your i2c controller, it may show arbitration error or something of that sort.
  • If any of the errors, read the i2c slave part datasheet carefully to check what types of protocol read/write it expects and fix your code.
Adashi
  • 461
  • 1
  • 4
  • 8