AnsweredAssumed Answered

strange interrupt behaviour

Question asked by Mr_M_from_G on Aug 18, 2014
Latest reply on Aug 19, 2014 by Clive One
I hope someone can explain this strange behaviour using interrupts on a STM32L151:
I send out data via a UART using a software ring buffer. To know how much data are there to be send I use an integer counter variable. Data is fed into DR register in an interrupt routine (TXE). So there is a need to change the counter inside (reading the buffer) and outside (filling the buffer) the interrupt service routine. Therefore outside the isr before incrementing the counter I disable the interrupt (clearing TXEIE) and enable it again afterwards.
But that fails. Still my buffer gets corrupted after pretty short time.
A solution I found is to insert a number of nop after clearing TXEIE and I found that I need exactly 7 nops to make it run, well at least much longer without any corruption as far as I can tell now. With 6 nops it still fails pretty fast.
Where does this behaviour come from?
How can I make an interrupt disable become active at once after the respective line of code ?

Thanks a lot for any hint.