Question
Rx interrupt showing frame error
Posted on February 28, 2013 at 16:54
I have to receive a data on my stm32f100 microcontroller which is sent from a software on PC through RS232 port. I am using IAR C compiler and in the interrupt handler i have some further sensor related program .Hope it is not confusing. This data is an information about an optical sensor attached to the microcontroller. The fixed timed sequence tobe sent from PC is as follows :
F8 FE A2 00 80F8 FE A2 00 80F8 FE A2 00 80 (Hex values) I have to make an interruopt routine such that it receives the above sent data and as soon as it receives ''A2'' the software returns to main program where corresponding SENSOR data is sent back using transmit interrupt. Now i have made the interrupt handler where the interrupt is called everytime there a data arrives at the serial port . Through debug i see the data arriving correctly to my microcontroller but i see that always there is an frame error or overrun error .I want these error to be removed. I have following setting for USART:- Parity-Even Stop bit-1 Baud rate 38400 Data bit -8 bit Hardware control -None USART_Mode=USART_Mode_Rx | USART_Mode_Tx; Can anyone tell me what could be the reason for the frame error or overrun error? and how can i remove it?.void USART1_IRQHandler(void)
{
//RxInterrupt
USART_ClearITPendingBit(COM_USART,USART_IT_RXNE );
UINT8_T rxData = USART_ReceiveData(COM_USART);
if (rxData==0xA2) {
pal_test1_on();
pal_test1_off();
}
// errors don't have to be indicated, they will be discarded anyway...
// iolDevice.DL.Message_handler.PL_Transfer_ind(rxData, PL_FRAMING_ERROR);
if((USART_GetFlagStatus(COM_USART, USART_FLAG_FE) ||
(USART_GetFlagStatus(COM_USART, USART_FLAG_ORE) ||
(USART_GetFlagStatus(COM_USART, USART_FLAG_PE)))))
{
rxData= ( UINT8_T)(USART1->SR & ( UINT8_T)0xFF); //read status
//then read data register ...
rxData = ( UINT8_T)(USART1->DR & ( UINT8_T)0xFF);
}
else
{
//IO-Link now wants some attention
pal_eRequestState = PAL_IOLSTATE_ACTIVE_REQUEST;
//when not in COMx-Mode, send WakeUp-Request
if (pal_eMode != IOL_PL_MODE)
{
iolDevice.DL.DL_mode_handler.PL_WakeUp_ind();
}
#if IOL_PAL_RX_USES_POLLING == 1
RxBuffer[RxBufferInpos] = rxData;
RxBufferInpos = (RxBufferInpos + 1) & RXBUF_MASK;
#else
iolDevice.PL.receiveByte(rxData);
#endif
}
}