2013-03-18 07:42 AM
Hi All
I have a driver for I2C master mode which has been working correctly under normal conditions. It is interrupt driven so the interrupt fires for each received/transmitted byte. If however non-present slaves are addressed the I2C bus hangs in a state with the SCL line low since the slave didn't acknowledge. In order to detect this I have activated the Error Interrupt (ITERREN) and would like to terminate the bus correctly (stop condition or repeated start) so that the bus can be used further. However, when the slave doesn't answer the AF bit gets set in SR1 as expected, the interrupt is enabled (0x072a in CR2) - this enables ITERREN, ITEVTEN and ITBUFEB - but there is never an interrupt from the I2C channel. All other interrupts are operating normally in the system. I am testing on I2C1 and I get no problem as long as I address a slave that acknowledges (always interrupts). Does anyone know how to get the error interrupt to fire?? Regards Mark #i2c-error-interrupt2013-03-19 03:02 AM
You surely have both I2C interrupts enabled, then, and have written both ISRs?
Any code to show us? JW2013-03-19 04:30 PM
Hi JW
I thank you for the hint that the error interrupt is a second vector - I didn't realise that and was expecting the same interrupt to fire as when there is a successful transfer. So I entered the I2C error interrupt (pointing it to the same interrupt handler that was already checking for the AF flag) and then I managed to verify and complete the driver.The next time I must first check to see how many interrupt vectors a single peripheral actualls has! Thanks again and regards Mark