AnsweredAssumed Answered

USART ore after 8 bytes always

Question asked by mccarty.michael on Dec 28, 2012
Latest reply on Apr 17, 2013 by bhiman.raghavendran
Hello All,
  I'm sending data over a bluetooth device to the stm32 discovery board on usart 2. Everything is great unless I send a large amount of data (80 bytes). If I send this large amount I only end up actually getting 8 bytes and the ORE error is set. I've read up on all the other posts and tried to implement the solutions but it had no effect what so ever. I must be doing something stupid here. Why would it always stop on 8 bytes ? 
01./**
02.  * @brief
03.  *      
04.  *        
05.  * @note  
06.  * @param  none
07.  * @retval none
08.  */
09.void USART2_Config(void)
10.{
11.    USART_InitTypeDef       USART_InitStructure;
12.    NVIC_InitTypeDef        NVIC_InitStructure;
13.     
14.    //Usart2_GPIO();
15.    GPIO_InitTypeDef GPIO_InitStructure;
16.     
17.    #ifndef STM32F10X_LD_VL
18.    GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
19.    #endif
20. 
21.    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE);
22.    RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2, ENABLE);
23. 
24.    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
25.    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;           
26.    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 
27.    GPIO_Init(GPIOA, &GPIO_InitStructure);        
28. 
29.    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
30.    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;          
31.    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
32.    GPIO_Init(GPIOA, &GPIO_InitStructure); 
33.    USART_Cmd(USART2, DISABLE);
34. 
35.    /* Enable the USARTz Interrupt */
36.    NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
37.    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
38.    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
39.    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
40.    NVIC_Init(&NVIC_InitStructure);
41.     
42.    USART_InitStructure.USART_BaudRate = UARTBAUD;
43.    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
44.    USART_InitStructure.USART_StopBits = USART_StopBits_1;
45.    USART_InitStructure.USART_Parity = USART_Parity_No;
46.    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
47.    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
48.    USART_Init(USART2, &USART_InitStructure);
49. 
50.    // enable this int to trigger dma ?
51.    //USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
52.    //USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
53. 
54.    // setup dma for usart
55.    USART_DMACmd(USART2, USART_DMAReq_Tx | USART_DMAReq_Rx, ENABLE);
56. 
57.    // hold onto your butts
58.    USART_Cmd(USART2, ENABLE);
59.}
60. 
61.void USART2_IRQHandler(void)
62.{
63.    u8 statusReg = 0;
64.     
65.    statusReg = (int8_t)(USART2->SR & (uint8_t)0xFF);  //read status
66. 
67.    while(statusReg &  (USART_FLAG_RXNE | USART_FLAG_ORE))
68.    {
69.        rxByte = USART_ReceiveData(USART2);
70. 
71.        // if we were getting data store it
72.        if(statusReg & USART_FLAG_RXNE)
73.        {
74.            cbWrite(&rxUSCBuff, &rxByte);
75.             
76.            if(cbIsFull(&rxUSCBuff))
77.            {
78.                /* Disable the USARTy Receive interrupt */
79.                //USART_ITConfig(USART2, USART_IT_RXNE, DISABLE);
80.                // mark buffer overflow
81.                mygVars->status |= ERR_PKT_OF;
82.            }
83.        }
84. 
85.        // read status again !
86.        statusReg = (int8_t)(USART2->SR & (uint8_t)0xFF);  //read status
87.    }
88.     
89.    if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)
90.    {
91.        USART_ClearFlag(USART2,USART_FLAG_RXNE);
92.    }
93.}

Outcomes