Hi. I am working through some I2C code, and we would like to be able to trigger reads and writes from/to the I2C interface and use interrupts to handle completed events. We don't wish to have I2C interrupts on all the time, nor do we wish to deal with all the various interrupts (Tx Empty, Rx Over, etc.)--just Rx Full, mostly.
For instance, we would like to trigger 30 reads (that number could change) and get an I2C interrupt when the receive FIFO exceeds the threshold (Rx full condition).
I can't get the R_RX_FULL interrupt to fire, however.
Here's what I've tried so far:
- In i2c_init( ), call NVIC_DisableIRQ(I2C_IRQn) and NVIC_SetPriority(I2C_IRQn,1) just for initial setup
- Unmask the Rx FIFO Full Interrupt with
SetWord16(I2C_INTR_MASK_REG, 0x0000);
SetBits16(I2C_INTR_MASK_REG, R_RX_FULL, 1); - Clear pending IRQs with
NVIC_ClearPendingIRQ(I2C_IRQn);
- When the Rx FIFO Full interrupt is desired to be enabled, I first set the Rx FIFO threshold with
SetWord16(I2C_RX_TL_REG, numBytesToRx - 1)
. - Then I send the read commands in a tight for loop. This loop should be done much faster than the bytes can be read from the I2C interface.
- I then enable and clear pending IRQs with
NVIC_EnableIRQ(I2C_IRQn)
andNVIC_ClearPendingIRQ(I2C_IRQn)
.
Any thoughts? Am I doing something wrong here?
Keywords:
Device:
Hi joe.brackman,
Please check the post below and follow the steps.
http://support.dialog-semiconductor.com/i2c-data-transfer-size
I cant see anything wrong in your code, with the enable, disable NVIC you should be able to have the interrupts hit.
Thanks MT_dialog