cancel
Showing results for 
Search instead for 
Did you mean: 

USART blocked

silvia
Associate II
Posted on October 26, 2010 at 12:12

USART blocked

#usart
7 REPLIES 7
John F.
Senior
Posted on May 17, 2011 at 14:12

This is normal. See the notes in the fragment from my USART3 handler below.

void USART3_IRQHandler(void)

{

  //this interrupt could be entered as a result of a usart overrun error ORE: Overrun error

  //This bit is set by hardware when the word currently being received in the shift register is

  //ready to be transferred into the RDR register while RXNE=1. An interrupt is generated if

  //RXNEIE=1 in the USART_CR1 register. It is cleared by a software sequence (a read to the

  //USART_SR register followed by a read to the USART_DR register).

  //if overrun, read status register first ...

  if(USART3->SR & USART_FLAG_ORE)

  {

    Usart3RxBuffer = (int8_t)(USART3->SR & (uint8_t)0xFF);  //read status

  }

  //then read data register ...

  Usart3RxBuffer = (int8_t)(USART3->DR & (uint8_t)0xFF);

Posted on May 17, 2011 at 14:12

I do not now why my usart goes to the state of blocked.

What are you doing with the data? Are you programming the flash memory?

If you are overrruning the USART you need some flow control. You probably need to clear things like parity or framing errors as they will stick too.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
silvia
Associate II
Posted on May 17, 2011 at 14:12

I received data from a radio transceiver, i store data in a buffer, then i read them to look for a specific bytes. I have a circular buffer to store the data.

silvia
Associate II
Posted on May 17, 2011 at 14:12

I write this code on the IT but and the USART go to the state of blocked.

I read always the flag ORE.

void USART2_IRQHandler(void)

{

  /*Rx*/

  if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)

  {

    USART_ClearFlag(USART2,USART_FLAG_RXNE);

     USART_GetFlagStatus(USART2,USART_FLAG_ORE);

    RadioRxFifosBuffDato[Radio.RxFifo.ColIndex]=USART_ReceiveData(USART2);   

  }

}

John F.
Senior
Posted on May 17, 2011 at 14:12

You have called your ''circular'' buffer a FIFO ... not the same thing! Either way, if you are getting ORE overrun errors it's because you are not servicing the UART in time to fetch one char out of it before it's trying to put another character in. Somewhere in the rest of your code, something is blocking the UART interrupt - or a higher priority interrupt is stealing time.

Posted on May 17, 2011 at 14:12

I write this code on the IT but and the USART go to the state of blocked.

 

I read always the flag ORE.

 

 

void USART2_IRQHandler(void)

 

{

 

  /*Rx*/

 

  if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)

 

  {

 

    USART_ClearFlag(USART2,USART_FLAG_RXNE);

 

     USART_GetFlagStatus(USART2,USART_FLAG_ORE);

 

    RadioRxFifosBuffDato[Radio.RxFifo.ColIndex]=USART_ReceiveData(USART2);   

 

  }

 

}

 

Note

1) Reading the receive data register clears the RXNE flag implicitly

2) Reading the ORE flag doesn't clear it

3) The ORE and parity/framing flags may be set in cases when RXNE is clear

4) Check for flags outside the RXNE handling code

5) You have to read the receive data register to clear the sticky errors

6) You should probably test the sticky bits in Tx routines, in case you don't get/handle the interrupt.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
silvia
Associate II
Posted on May 17, 2011 at 14:12

I have never worked with usart ITx, so i suposed the data change during the ITx, i suposed this because i saw it with the debugger. Now i understand that the ORE flags is set after read de data.

 I tried to check for flags outside the RXNE handling code. By the moment the system works correctly. Very many thanks.

But I have another question:

In the system i work with three peripheric. SPI, I2C and the UART. The priority, high SPI, I2C, and less UART. Inside the UART ITx i need to utilize the SPI ITx. Can i have problems with this?