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 everyone,

    It's too late now, but the problem that I2C appears to be running at 200 kHz has been resolved. This occurs when I2C is run using the built-in pull-up.

    Don't forget implement external pull-up resistor. (especially ME) 

    Oh, and before I know it, there is a non-blocking i2c sample project. I solved this problem using that project.
    I assume that the TWI API uses asynchronous callbacks internally, which makes it difficult to implement in the API, so this is the way to do it.

Children
Related