I2C Clock Stretching


I'm trying to implement a driver for the Adafruit BDO055 9DOF Absolute Orientation sensor board to work with a viperised Photon.

The BDO055 sensor requires Clock Stretching to work with I2C correctly. 

I can see from the original Particle Photon documentation that Clock Stretching was part of the I2C functionality (Wire.stretchClock(stretch) 

Is this functionality available within the Zerynth Photon Python VM implementation? 


  • Hi andolph,

    Zerynth I2C implementation should allow by default Clock Stretching in Master mode, but since we have not tried it, are you experiencing unexpected behaviours?
    Lorenzo Rizzello
    Zerynth Support Team

  • Hi Lorenzo

    In the original photon (non python) setup, Clock Stretching has to be specifically switched 'on' using the Wire.stretchClock(stretch) instruction.

    Is it correct that Clock Stretching is 'on' by default in the Zerynth Photon?

    If not, I can't see anyway, within the Zerynth photon software implementation, of switching Clock Stretching 'on'.

    Could you suggest how this could be achieved?
  • Hi andolph,
    from Wire.stretchClock() implementation
    void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
    /* Check the parameters */
    if (NewState == DISABLE)
    /* Enable the selected I2C Clock stretching */
    I2Cx->CR1 |= I2C_CR1_NOSTRETCH;
    /* Disable the selected I2C Clock stretching */
    I2Cx->CR1 &= (uint16_t)~((uint16_t)I2C_CR1_NOSTRETCH);
    we see how they only clear the NOSTRETCH bit in the I2C control register when stretching is needed.
    As concerns Zerynth I2C, that bit is left to 0, so you do not have to enable it manually :)

    Let us know if something does not work anyway ;)
    Lorenzo Rizzello
    Zerynth Support Team

Sign In or Register to comment.

ZERYNTH Community

@ 2016, all rights reserved.