I have developed an app to use JNI to control a self-developed I2C device but encounter some problems. The I2C device can accept at most 37.5kHz, so that I modify the clock rate in device tree.
The app will keep write to the I2C every 20ms and will not do anything when it does not receive ACK from the device. When the I2C device is disconnected, the board can still work. But when I change the polling period to 10ms or less, the board will freeze after receiving many NACK. Before the board freezes, the system slow down and the mouse is lagging behind. If I add more debug messages in i2c-msm-v2, the board also freezes easily.
The app will write 16 bytes data to the device. Monitor the waveform with oscilloscope and find that sometimes the clock and data will drift a little at the middle of a byte transfer. The I2C bus has one device only. Also, I can see that there is i2c_lock_adapter(adap) in the code to protect it from concurrent access.
Can anyone advise how to debug the above problems?
Many thank in advance!