• The code was indeed running at around 250kHz, according to the data sheet of the radio module it supports up to 400 kHz so it should have worked, but for some reason it doesn't.
    The I2C signals look correct, except for the following artifacts.

    The espruino version has these artifacts on the signal that don't exist on the mongoose version.

    I cannot get higher resolution out of my logic analyzer but
    the peak and dip coincide with the clock signal. In the code it seems to reapply the value of sda at each scl change :

    i2c_master_writeByte(uint8 wrdata)
    {
        uint8 dat;
        sint8 i;
    
        i2c_master_wait(2);
        i2c_master_setDC(m_nLastSDA, 0);
        i2c_master_wait(4);
    
        for (i = 7; i >= 0; i--) {
            dat = wrdata >> i;
            i2c_master_setDC(dat, 0); // << set sda when clock still low
            i2c_master_wait(1);
            i2c_master_setDC(dat, 1); // << set sda to same value but now with clock high
            i2c_master_wait(5);
            i2c_master_setDC(dat, 0); // << set sda to same value but with clock low again
            i2c_master_wait(2);
        }
    }
    

    I wonder if setting sda to 1 actually pulls it to 0 first before reapplying the 1.
    I cannot see any other problems when comparing the signals generated by espruino with the ones generated by mongoose :

    Note that the following images are using a lower sample rate so that is why the rise times look slow and it doesn't show the artifacts.
    Things to note: In this version of espruino I slowed down the I2C speed to match the mongoose speed, it is using the clock stretching version of i2c_master.c. Besides some slight timing differences to better match mongoose this should otherwise be the same as the version of this file in the master espruino branch.


    Espruino signal, notice it doesn't get ack.


    Mongoose signal, notice it does get ack (and does so consistently) .

    It looks like mongoose allows clock stretching also, but that happens after ack so should not be the cause of the difference.

    You can imagine that I am positively stumped why mongoose works consistently correct while Espruino consistently fails.

About