2013-09-05 09:30 AM
Hi,
I am usingSTM324x9I-EVAL, which has a 32F439 chip with Keil tools chain and StdPeriph Lib, 1.2RC2, FreeRTOS 7.5.The following is the section of interrupt code.void USART1_IRQHandler(void){ portBASE_TYPE higherPriorityTask; if(USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET) { // Read one byte from the receive data register // aRxBuffer[uhRxCounter++] = (USART_ReceiveData(EVAL_COM1) & 0x7F); while (aRxByte != 0) vTaskDelay(5); aRxByte = USART_ReceiveData(EVAL_COM1); if (xSemaphoreGiveFromISR(semaRXDAvail, &higherPriorityTask) == pdFALSE) errorReg[EBUartRXSemaFail] |= EMUartRXSemaFail; }......The program works well if the input is ''normal'' characters. However, when the received char is 0x1B (escape). Then it will wandering inside the stm32f4xx_usart.c and no longer getting any RXNE interrupt. What's the correct way to handle the escape sequence?Thanks,Sink.2013-09-05 09:53 AM
This looks awesome
while (aRxByte != 0) vTaskDelay(5); In the IRQ Handler do something and leave, don't be spinning in loops, or yielding to other tasks. Pretty much guaranteed to dead-lock. To process ESC sequences implement a simple state machine, and handle each character as it is received, buffer as required, flag for some deferred processing if required.2013-09-05 11:50 AM
Yeah,
Thanks, I just found out that my RX task is fast enough to handle the escape sequence and got buffer overrun interrupt. Need to check ORE in the ISR.Sink2013-09-05 11:51 AM
typo, 'is not'