USART escape sequence and interrupt.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-09-05 9:30 AM
Posted on September 05, 2013 at 18:30
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.
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-09-05 9:53 AM
Posted on September 05, 2013 at 18:53
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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-09-05 11:50 AM
Posted on September 05, 2013 at 20:50
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.SinkOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-09-05 11:51 AM
Posted on September 05, 2013 at 20:51
typo, 'is not'
