2010-10-26 03:12 AM
2011-05-17 05:12 AM
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);2011-05-17 05:12 AM
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.2011-05-17 05:12 AM
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.
2011-05-17 05:12 AM
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); } }2011-05-17 05:12 AM
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.
2011-05-17 05:12 AM
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.
2011-05-17 05:12 AM
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?