1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I'd say you've got a problem somewhere :), activity on SCK & SDA should definitely occur at the same time, in the same bursts of activity. That your "decoder" (whatever it is) isn't working is further evidence of this. Are you bit-banging this I2C interface,or using a dedicated I2C peripheral in your microcontroller to do this? \$\endgroup\$ – Techydude May 24 '15 at 7:13
  • \$\begingroup\$ @Techydude Yes, I'm bit banging here. I'm building on the BMP180 I2C implementation at github.com/reaper7/esp8266_i2c_bmp180/blob/master/i2c_bmp180.c \$\endgroup\$ – Kar May 24 '15 at 7:16
  • \$\begingroup\$ What functions are you calling for what is seen on the scope ? You using the recommended i2c library mentioned in the readme ? \$\endgroup\$ – efox29 May 24 '15 at 7:22
  • \$\begingroup\$ If you've never bit-banged a serial protocol before, then I suspect you've got yourself "temporally confused" in how your code is actually executing. What's your hardware platform? If you've got an I2C hardware peripheral there, use it - learn to walk before you try to run. If not, then leverage countless other bit=banged I2C implementations. \$\endgroup\$ – Techydude May 24 '15 at 7:41
  • \$\begingroup\$ Sorry, just noticed you're on the ESP8266 platform, which has no hardware I2C peripheral - hence the need to bit-bang. Alarmingly, the I2C bit-banging driver you're relying on: github.com/zarya/esp8266_i2c_driver says "This driver is far from perfect and still needs work", so there's a hint :) \$\endgroup\$ – Techydude May 24 '15 at 7:46
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

The I2C clock should be 1 when idle. Refer to the I2C stop condition. If you use a bit-banging function, Google existing examples, don't reinvent the wheel. And of course it's always better to use on-chip peripherals.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.