Why does the clock stay at high

clocki2c

I'm very new and I'm trying to do an I2C trace of ADXL345 with Ch1 to SCL and Ch2 to SDA, but the traces look like these:

enter image description here

enter image description here

Is the clock not supposed to oscillate continuously? Is it normal for it to stay high when data is being written (although the decoder fails to decode).

I wonder if I'm doing something wrong and missing something basic.

Best Answer

Also, given that you're bit-banging I2C on a microcontroller that's undoubtedly got "other things to do" (wifi on the 8266, right?), it's possible your bit-banged I2C program flow is being interrupted to handle wifi (or who knows what else), and possibly screwing things up. Perhaps you (the Zarya I2C library you're using) needs to be disabling interrupts for the duration of each I2C byte, or even each entire transaction to/from your I2C peripheral. You don't want to be interrupted part way through a byte: the I2C peripheral might time-out, but your bit-banged code is still 'in state' in the middle of a byte & has no idea xx mS just passed between a couple of its bits transmissions/receivings.

Related Topic