Hey everyone, I’m trying to understand something and I’m not sure where the issue is coming from, but it might be Xavier-related to I’m posting here for ideas. I have an MCP4725 I2C device. I’ve written code to control a voltage, and it works fine if I put a 1ms sleep timer in the loop that takes input and processes signals. If I remove the timer I get an OS error 121 a couple times upon load, then an OS error 110, then an OS error 5 over and over with the loop iterations.
Baud rate is set at 100000. I’ve tried all the baud rates in the datasheet and I get the same result. Wiring is good. i2c address is good. Any ideas?
Yes. I have a while loop that calls a method in a MCP4725 object connecting to bus 8 at address 0x60 (in this case) setting power to normal mode and writing an output digital value for the MCP to convert to an analog signal.
If I throw a 1ms sleep into the loop it works fine, but if I don’t I get the errors mentioned above.
I’ve edited bus block rate in sys/bus/i2c/devices/i2c-/bus_clk_rate. After saving the file, is there a service I need to reload or any other changes I need to make? Or is there a more proper way to handle this?
Also, I’ve noticed that without any sleep commands, the loop establishes a connection and executes successfully the first time, but on the second step of the loop it starts throwing the errors mentioned above. Erro 121 is also the same error I get if I unplug the MCP4725 in the first place.
Here are the errors. The first one occurs once, the following ones repeat until the program stops.
May 23 10:27:39 ubuntu kernel: [294861.141302] tegra-i2c 31e0000.i2c: I2C transfer timed out
May 23 10:27:39 ubuntu kernel: [294861.142433] tegra-i2c 31e0000.i2c: un-recovered arbitration lost
May 23 10:27:39 ubuntu kernel: [294861.143202] tegra-i2c 31e0000.i2c: un-recovered arbitration lost
Running i2cget on the device and 0x60 address returns 0xc0. There’s also a device always connected at 0x74 - I haven’t determined what it is yet. I’m assuming it’s something default in the system. The error I get is OS Error 5. I get OS error 121 when it’s disconnected or the address is wrong (same as being disconnected).
Update: I wrote another version in Python and it appears to work fine. My original code was written in Rust using the Rust MCP4725 library. So I’m thinking it’s a software issue. That said, any insights understanding the errors I saw would be appreciated in the event I try to dive into the Rust solution further.