Skip to main content
shendawaterloo
Associate
June 7, 2013
Question

USART IDLE interrupt for no reason?

  • June 7, 2013
  • 4 replies
  • 1346 views
Posted on June 07, 2013 at 09:16

hoping someone knows the answer to this...

when I send a character on usart2, SR->IDLE flag is set for no reason, RXNE = 0 but I can see the data in the DR. what weirds me out is IDLEIE is 0. 

so far I simple can't get RXNE to set at all.

this is on the stm32f107vc

#usart-interrupt #usart-idle
This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
June 7, 2013
Posted on June 07, 2013 at 13:51

How exactly are you looking at this? If from a debugger be aware that it will read the DR clearing bits in SR, ie it has no magic way of looking in this register without changing the state.

It might be helpful to show the code you're having a problem with, ideally a self contained example.
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate III
June 7, 2013
Posted on June 07, 2013 at 15:58

IDLEIE is used to gate an interrupt request when IDLE is asserted.  It doesn't disable the IDLE flag in SR.  What you are seeing is normal.  IDLE is set when RX sees an idle condition, no data arriving.  Reading DR when RXNE = 0 returns invalid data.

  Jack Peacock

shendawaterloo
Associate
June 7, 2013
Posted on June 07, 2013 at 17:29

Thanks, if that's the case how do you test irq handler?

My code follows these:

void uart_handler()

{

if(USART2->SR & USART_SR_RXNE)

{

data = USART2->DR;

//do something

}

}

but putting a breakpoint at the if statement will read and clear the RXNE?

should i put the breakpoint after the DR read then?

Tesla DeLorean
Guru
June 7, 2013
Posted on June 07, 2013 at 18:41

I was thinking of debugger based peripheral viewers.

I'd put the break-point on the data read. If you are not getting received data you'll need to check your clocks and baud rates, and how the data is delivered to the pin.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..