cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 I2C interupt not being pended

HoangHung
Associate

I am trying to write my own I2C driver but I have been having an issue that after sending the start condition both SCL and SDA lines go low and stay that way. After some painful debugging I realize that the I2C event interrupt handler is not being called, which I rely upon to write to the data register.

I tried to set pending the interrupt manually and the handler was invoked and a byte got send through, so I know that for some reason the hardware is just not pending it. I don't know why that is. Can anyone help?

3 REPLIES 3

Read out and check/post the I2C registers content.

A generic "interrupt does not fire" checklist here.

JW

Thank you for the reply. These are the values of the i2c registers.

I2C2_CR1       0x00000401 = PE | ACK

I2C2_CR2       0x00000324 = ITERREN | ITEVTEN | FREQ (=36)
I2C2_OAR1    0x00000000
I2C2_OAR2    0x00000000
I2C2_SR1       0x00000001 = SB
I2C2_SR2       0x00000003 = MSL | BUSY
I2C2_CCR      0x000000B4 = CCR (=180)
I2C2_TRISE   0x00000025

The checklist did not add much.

 

As both SB and ITEVTEN are set, and you're confident there's nothing else from the checklist which would prevent the interrupt to run, I am out of ideas, sorry.

JW

PS. You are aware of the fact that many 'F103 these days are counterfeit, aren't you.