I2C locks up/stuck forever #370
Replies: 3 comments
-
Hi! First thing I'd try is whether combining the write and read into a let _ = self.i2c.write(self.address, &[OBJECT_TEMPERATURE]);
let _ = self.i2c.read(self.address, &mut buffer)?; to let _ = self.i2c.write_read(self.address, &[OBJECT_TEMPERATURE], &mut buffer)?; If this doesn't help, I'd give each of the read-loops an upper bound and return an individual error code when it is hit (just add new ones to the error enum). You can then print out the errors in your BTW, our error type implements Err(e) => {
ufmt::uwriteln!(&mut serial, "Got {:?} error!\r", e).void_unwrap();
} Let me know how this goes... I guess it would be nice to include some easier way to debug such issues in |
Beta Was this translation helpful? Give feedback.
-
I used read write initially and i found the bug. A different proposal i think an improved the project template would be like : This makes it easier to debug and verify the code that you write yourself. (up to a point).
[dependencies]
embedded-hal = "0.2.3"
[dev-dependencies]
embedded-hal-mock = "0.8.0" |
Beta Was this translation helpful? Give feedback.
-
Dear Rahix,
I've implemented some code to read the temperature sensor MLX90614
I already tested the sensor itself using the sample from adaFruit and that works fine.
But it always start to hang after several reads but sadly i don't really know on how i can debug this in rust (i'm new to rust).
I verified that there is no panic by enabling the logging panic from the examples. (sadly i don't have a JTAG debugger to know where the code is stuck).
I suspect that it is stuck in one of the loops but i'm not sure on how to verify this:
while self.twcr.read().twint().bit_is_clear() {}
avr-hal versions tried:
533159f6c6a508abe4ecec34bf5013d7a1eb0cf5
// latest branch3b8f39fa2ec5e3359c7bedc33d982e75e8cc3700
//default cargo initresult:
Beta Was this translation helpful? Give feedback.
All reactions