TWIM (I2C) on NCS is not working properly.

First of all, the fast mode should be 400kHz, but it seems to be only 200kHz according to the waveform. Also, the duty cycle seems to be wrong.

Secondly, It seems that CONFIG_I2C_CALLBACK is not working at all. I have written the callback function as follows, but it is not called.

/* Callback */
K_SEM_DEFINE(k_sem, 0, 1);
static void twim_callback(const struct device *dev, int result, void *data)
{
    printk("Callback\n");
    k_sem_give(&k_sem);
}
That is obvious since there is no log display and no semaphore to go through.
I am working on a project using TWIM and I hope these bugs will be fixed soon.
Parents Reply
  • Hello,

    I am really sorry for the delays, I am struggling a bit to find out about the internal workings of zephyr's I2C driver myself.

    I am trying to consult my colleagues to get more insight into that.

    You may want to look into the nordic's zephyr I2C driver in ncs/zephyr/drivers/i2c, i2c_nrfx_twim.c and i2c_nrfx_twi.c as well.

    There you can find this snippet:

    static const struct i2c_driver_api i2c_nrfx_twim_driver_api = {
        .configure   = i2c_nrfx_twim_configure,
        .transfer    = i2c_nrfx_twim_transfer,
        .recover_bus = i2c_nrfx_twim_recover_bus,
    };

    Which sets the api->transfer to i2c_nrfx_twim_transfer.

    Best regards,

    Michal

Children
Related