2009-01-21 07:02 AM
Spurious I2C
2011-05-17 04:00 AM
Hi guys,
I'm using the STM32's I2C in a simple master-transmit mode, and I'm getting I2C event interrupts that I can't explain -- the interrupt occurs and both status registers are zero (SR1 == SR2 == 0). As far as I can tell from the datasheet and sample code, one should never get I2C interrupts unless at least *some* bits in SR1 or SR2 are set. My ISR looks something like this:Code:
void EventISR()
{ uint32 event = I2C_GetLastEvent(I2C2); if (event == I2C_EVENT_MASTER_MODE_SELECT) { I2CWrite(0x44<<1 | 1); // address of ISL29003, transmit } else if (event == I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) { I2CWrite(*_ptxByte++); } else if (event == 0x70080) { if (_ptxByte < _ptxEnd) { I2CWrite(*_ptxByte++); } else { I2CStop(); } } else { SpuriousEvent = event; NumSpuriousEvents++; } }(Where I2CWrite() simply writes a byte to DR and I2CStop() writes to CR1 to send a stop bit.) Note also that I'm looking for 0x70080 instead of I2C_EVENT_MASTER_BYTE_TRANSMITTED (which is 0x70084) as per the example, because in my tests I'm not seeing the BTF flag set. I'm not 100% clear on the meaning of BTF from the datasheet, but to me it looks like it shouldn't be set. Anyone else had either of these problems, especially the I2C interrupts with the status registers zero? Cheers, Ben.2011-05-17 04:00 AM
Hi Loeffel, thanks for the reply. Good to know someone else is getting those interrupts too. And I'll look up other posts about I2C issues in this forum -- thanks! (I had a brief look, but wasn't very thorough.)
2011-05-17 04:00 AM
Hi Ben
I can confirm that there is an interrupt with no status information. At our application ( I2C Master Transmitter, Receiver ) it happens after a restart condition. There are some additonal events which aren't defined at the header file especially if you setup a interrupt driven system. There are some other recommendationat/experiences posted at this forum about the i2c regards