DUELink and I2c

For testing, I try to read register 0 as the value never changes, I know what I should read.
After, when writeRegister (done with your great help) and readRegister (not working) functions will be operationnal, I will have to read register 3 to know button state.

Of course, I will share code when it’s working (it could even be a sample for non duelink module).

Hi,

We’ve double-checked and tested the DLI2CWr function, and we don’t see anything wrong with it yet.

Could you share your read function?

Were you able to read the ID successfully?

fn ReadR(a,r)    
    Dim B1[]=[r]
    Dim B2[]=[0]
    # Write 2 bytes to adress and read nothing
    DLI2CWr(a,B1,[])
    DLI2CWr(a,[],B2)
    return B2[0]
fend

From a Fez Pico, with TinyClr, I can read the ID:

            var writeBuffer = new byte[] { 0x00 };
            var readBuffer = new byte[] { 0x00 };

            var settings = new I2cConnectionSettings(0x6F, 400_000); //The slave's address and the bus speed.
            var controller = I2cController.FromName(SC13048.I2cBus.I2c1);
            var device = controller.GetDevice(settings);

            device.Write(writeBuffer); //This is good for reading register
            device.Read(readBuffer); //This is good for reading register

            Debug.WriteLine("Read: " + readBuffer[0].ToString("X"));

We’ve tested and haven’t found any issues.

We’ll order the button to check.

1 Like

Seems this button support repeat start, so can you try:


fn ReadR(a,r)    
    Dim B1[]=[r]
    Dim B2[]=[0]
    DLI2CWr(a,B1,b2)
    return B2[0]
fend

Alas, it’s not working. :sob:
Here my complete code:

# Switch Downlink to I2C mode
fn WriteR(a,r,v)    
    Dim B1[]=[r,v]
    # Write 2 bytes to adress and read nothing
    DLI2CWr(a,B1,[])
fend
 
fn ReadR(a,r)    
    Dim B1[]=[r]
    Dim B2[]=[0]
    DLI2CWr(a,B1,B2)
    return B2[0]
fend
 
DLMode(5,0)
while 1
    WriteR(0x6f,0x19,0x01)
    Wait(220)
    WriteR(0x6f,0x19,0x0)
    Wait(800)
    println("R: ",ReadR(0x6f,0x00))
    Wait(220)
wend

No worries, we ordered a few modules to test. I am very curious myself because everything looks fine with the other boards we tested but we couldn’t find the sparkfun button.

1 Like

One more thing you can try, there is v0.67 release yesterday, it fixed internal pullup.

We see the button already has pullup, but try v0.67 to see. If v0.67 work mean somehow the external pullup on the button does not work correctly.

I’ve seen it this morning and give it a try… but without success. I’ll wait you receive the module.

I’ve checked with a BME280 qwiic module, it’s perfectly working, so it’s module specific.

1 Like

Check if the non-working module actually has the pull-ups installed?

From the docs, both have pull up (and I owe 4 buttons modules, I have checked all of them, and no one is working).

Is it possible that the documented address is wrong? That would explain no response.

He was able to write just fine but read doesn’t work! I am very curious about this.

I just received some modulino modules and I can write just fine but I can’t get read to work. Maybe I am doing something wrong but I do not have an analyzer at home to check.

I also tried Sparkfun Qwiic joystick and also no luck. I am guessing we have a bug in restart conditions.

…we are still looking into this.

1 Like

This is bad news but I think this a good news too: GHI team will find a solution ! I suspect that it is a “software bug” (easier to correct as “hardware bug”).

Yes software not hardware. We can write just fine.

1 Like

Firmware v0.68 has been released, hopefully, it will resolve the issue.

1 Like

@Bauland turned out we have a bug in how we handle clock stretching. The devices we have used before did not use clock stretching. We teste this sparkfun qwiic joystick, not button. It should work now but we need to to check and confirm please.

1 Like

@Gus_Issa and @Dat_Tran : you are the best ! Problem is solved :clap:

3 Likes