Hi,
We are using the DEBUG UART to send out data on a consecutive basis which worked just fine. Now we added a feature where we also want to receive some command characters so I added Interrupt control to the UART but it turns out, that when the program starts,m it first expects to receive a character before it starts sending out any data (which is not whast we want) also, it seems that it stop sending after every character I send from the terminal and only resumes when it receives an even number of chars.... why is this and how can I fix it?
My code looks like this:
//Macros
#define DEBUG_UART UART0
#define DEBUG_UART_IRQn UART0_RX_TX_IRQn
#define DEBUG_UART_IRQHandler UART0_RX_TX_IRQHandler
//enabling the interrupt
UART_EnableInterrupts(DEBUG_UART, kUART_RxDataRegFullInterruptEnable | kUART_RxOverrunInterruptEnable);
EnableIRQ(DEBUG_UART_IRQn);
//ISR
void DEBUG_UART_IRQHandler(void) {
uint8_t rxChar = 0U;
/* If new data arrived. */
if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(DEBUG_UART))
{
rxChar = UART_ReadByte(DEBUG_PERIPHERAL);
if(rxChar == '*') {
toggleDebugging();
} else if (isDebugging()) {
setMode(rxChar);
} else {
if(rxChar == '@'){
receivingCommandFlag = true;
rxIndex = 0;
inCommingFlag = false;
}else if(receivingCommandFlag){
rxBuffer[rxIndex] = rxChar;
rxIndex++;
if(rxChar==0xa || rxChar==0xd){
inCommingFlag = true;
}
}
}
}
SDK_ISR_EXIT_BARRIER;
}
What is wrong or what am I missing? Any help is appreciated!
已解决! 转到解答。
It seems like it might have to do something with UART_GetStatusFlags() as this is where it hangs when I suspend the session (while it doesn't send characters due to having received a single char). What's up with that, I'm confused!
The line looks like:
if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(DEBUG_UART))