Hi,
I have tried to timeout the i2c communication but failed to achieve through i2c interrupt method. First i enabled the SCLTIMEOUT and EVENTTIMEOUT bit in INTENSET register and configured the TIMEOUT register as 500, then i disconnected the clock PIN from the evk board. The EEPROM IC didn't acknowledge the slave address and it was held in a loop for long time. Can you suggest me how to achieve the timeout in i2c interrupt communication?
Hi,
Because there is pull-up resistor on both the SCL and SDA pin, if you disable SCL, the SCL pin will be high, and SDA is also high, this is idle mode, timeout mechanism does not take effect.
For a test, during the I2C transferring process, you can connect the SCL to GND manually, then the timeout will take effect.
Hope it can help you
BR
XiangJun Rong
Hi,
Pls try to post your code so that we can have a review.
BR
XiangJun Rong
Hi,
First of all, I have initialized the I2C bus. Then send data through i2c interrupt concept. Hereby I have attached the code for your reference.
SYSCON->AHBCLKCTRLSET[1] = 1 << 12;
SYSCON->PRESETCTRLSET[1] = 1 << 12;
SYSCON
->PRESETCTRLCLR[1] = 1 << 12;
FLEXCOMM1->PSELID = 0x101073;
I2C1->CFG = 0x01;
I2C1->CLKDIV = 0x07;
I2C1->TIMEOUT = 5000;
I2C1->MSTTIME = 0x56;
I2C1->INTENCLR = (1 << 0) | (1 << 4) | (1 << 6) | (1 << 24) | (1 << 25);
And the following i have used it while transmitting data through I2C interrupt.
I2C1->INTENCLR = (1 << 0) | (1 << 4) | (1 << 6) | (1 << 24) | (1 << 25);
I2C1->STAT = (1 << 4) | (1 << 6) | (1 << 24) | (1 << 25);
I2C1->INTENSET = (1 << 0) | (1 << 4) | (1 << 6) | (1 << 24) | (1 << 25);
I2C1->MSTDAT = I2C_Slave_addr | write_bit;
I2C1->MSTCTL = 0x02;
Hi,
I have not seen the NVIC module configuration, pls try to use the instructions.
__NVIC_EnableIRQ(FLEXCOMM0_IRQ1);
__NVIC_SetPriority(FLEXCOMM0_IRQ1,0x00);
Hope it can help you
BR
XiangJun Rong