cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Slave Cannot Clear STOPF Flag

dclark9
Associate II
Posted on July 19, 2012 at 17:50

Hi,

Another small littleconundrumI am hoping someone out there might help me solve. I have got an i2c master and slave talking to each other, I'm fairly sure the Master code is good as it's been working with other non stm32 slave devices. The Slave however is a different story, although I've actually got it working reasonable i.e. I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED, setup DMA to transfer data all of which it is doing. Unfortunately my I2C IRQ call is getting itself into an infinite loop whereby an interrupt is triggered, and it's alwaysI2C_EVENT_SLAVE_STOP_DETECTED. I've tried clearing it using the following commands (after stopping the DMA) :-

I2C_ClearFlag(I2C1, I2C_FLAG_STOPF);
 
 (void)(I2C_GetITStatus(I2C1, I2C_IT_STOPF));
 
 while(!I2C_CheckEvent(I2C1, I2C_EVENT_SLAVE_STOP_DETECTED))

but the interrupt continues occurring, and checking the code the other end it doesn't appear to be getting repeatedly generated by the Master. Many thanks for any responses in advance. Dave
1 REPLY 1
frankmeyer9
Associate II
Posted on July 19, 2012 at 20:50

Albeit I avoid the I2C peripheral, I had a similar problem with the ADC. The code was cycling endlessly in the interrupt routine.

Do you check for ALL interrupt flags, and do you clear ALL pending flags in the interrupt routine ?

If you leave a pending flag set, the interrupt restarts immediately.

The trap is, some flags like RXNE or ADC_EOC are automatically reset when reading the Data register, most others not.