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 freeze. Custom NRF52 #199

Closed
snowneki4 opened this issue Oct 3, 2017 · 6 comments
Closed

I2C freeze. Custom NRF52 #199

snowneki4 opened this issue Oct 3, 2017 · 6 comments

Comments

@snowneki4
Copy link

I have a custom nrf52 board and i need to get MPU6050 running. I have connected it using following pins:
#define PIN_WIRE_SDA (3u)
#define PIN_WIRE_SCL (21u)
Both pins have 4.7k resistors connected.
I have not yet implemented MPU6050 library, though i am trying to recognize the device using I2C scanner described here: https://playground.arduino.cc/Main/I2cScanner Code i am using is there.
Whenever sensor is disconnected terminal continues to show No I2C devices found. Which is right. But whenever i connect sensor to the pins it freezes after the scanning stage.
So, questions. Originally pins for SDA/SCL were 20/21 in variants.h. Can i actually change those?
Can you point me what am i doing wrong?

My skills arent very high, so could be i am doing something completely stupid.

@micooke
Copy link
Contributor

micooke commented Oct 5, 2017

See #176

@lichtheini
Copy link

Maybe I can help: I have an Adafruit Feather nRF52 and a MPU9250, so much the same condition. There are many points were your code or wiring could be wrong. I just show the one, that took me a while to figure out: a hanging I2C-bus with SDA low.

My solution, well, my workaround is described here: esp8266/Arduino#1025 (comment) and here.

if(digitalRead(PIN_WIRE_SCL) == HIGH && digitalRead(PIN_WIRE_SDA) == LOW) {
      //Serial.println("reset i2c bus");
      pinMode(28, OUTPUT);  // connect parallel to SCL
      digitalWrite(28, LOW);
      delay(200); 
      pinMode(28, INPUT);
      delay(50);
      NVIC_SystemReset();
}

And yes, almost any pins are usable for I2C communication.

The GPIOs used for each two-wire interface line can be chosen from any GPIO on the device and are
independently configurable. (Product Spec rev 1.3, p. 305)

Hope it helps!

@snowneki4
Copy link
Author

Problem was somehow solved my selecting Generic NRF51 option from the board selection menu, even
though i am using nrf52 board.
It is described in the post micooke has mentioned.
thanks everyone

@micooke
Copy link
Contributor

micooke commented Oct 8, 2017

Glad it worked for you!
I'm sure this will be resolved in the near future for the nrf52. Im not sure if it helps, but you could also try this : https://github.com/micooke/SoftwareI2C

@snowneki4
Copy link
Author

snowneki4 commented Oct 8, 2017

Will give it a try as well. Thanks

@micooke
Copy link
Contributor

micooke commented Oct 8, 2017

No problem. I just realised its a little outdated (but should still work), ill try and push the latest revision tomorrow.
Only API changes i made are that sda, scl were removed from begin() and put into the constructor.

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

3 participants