AnsweredAssumed Answered

STM32F103 USART (overrun)

Question asked by sc0re.Over on May 14, 2014
Latest reply on May 15, 2014 by sc0re.Over
Hello,

I am using USART 1 at 115200 and today serious problems with USART overrun started to appear (yesterday everything was fine and I don't seem to remember any significant changes on this portion of the code). 
Single character transmission works, but as soon as I send two (or more) characters to the USART, overrun occurs. Only the first character is read, all others are lost. 

It looks like I can't read bytes from the data registers fast enough although I can't see why. 
Also I was pretty sure that the USART has a few bytes of FIFO buffer on the RX side but I'm not so sure anymore. 

Here's my UART interrupt routine: 

void USART1_IRQHandler(void)
{
static int c;
 
#if CoOS
    CoEnterISR();
#endif
 
    // ---------- TXE interrupt ------------------
    if( USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
    {
        c = rbFifo_get(&txFifo[0]);
        if (c == -1)    // Buffer empty, transmit complete
        {
            USART_ITConfig(USART1, USART_IT_TXE, DISABLE);      // Can't clear the TXE (cleared by writing into the DR) thus, disble int.
        }
        else
        {
            USART_SendData(USART1, c & 0xFF);                   // Send new char (TXE us cleared upon writing to TX reg.)
        }
    }
 
    // ---------- RXNE interrupt ------------------
    else if( USART_GetITStatus(USART1, USART_IT_RXNE) )
    {
        // Put data to circular buffer
        if (rbFifo_put(&rxFifo[0],USART_ReceiveData(USART1)) == -1)
        {
            error(ERR_FIFO_FULL, 0x11);
        }
#if CoOS
        isr_SetFlag(USARTx_rxFlag[0]);                          // Flag character received
#endif
 
    } else if (USART_GetFlagStatus(USART1, USART_FLAG_ORE) != RESET)
      {
        if (rbFifo_put(&rxFifo[0],USART_ReceiveData(USART1)) == -1)
                {
                    error(ERR_FIFO_FULL, 0x11);
                }
      } else
    {
        error(ERR_UNHANDLED_INT,1);
        USART1->SR = 0;
    }
 
 
#if CoOS
    CoExitISR();
#endif
}

Received bytes are just pushed to a RB fifo buffer and nothing else. Any suggestions on this matter would really be appreciated. 

Regards, 
over.

Outcomes