I'm trying to setup UART communication with the STM32F0 Discovery Board but I am having difficulty adapting the Rx side of things to my needs.
The STM32 will be receiving a message (4-6 bytes with no end character) from the UART device every few seconds and then must send a reply.
How should I be handling receiving messages so that I'm not limited to a fixed message size, so that I don't need to look for an end character (maybe using a timer) and so that glitches don't throw off my entire communications?
I'm debugging the below code with an FTDI USB-UART cable right now and the interrupt only triggers for the first character I send through terminal and then wont trigger again.
//This function handles USART1 global interrupt request.
void USART1_IRQHandler(void)
{
if( USART_GetITStatus(PMIC_COM1, USART_IT_RXNE))
{
char t = USART_ReceiveData(PMIC_COM1);
//Check if received character is end character
if( (t != 'x') && (cnt < MAX_STRLEN) ){
received_string[cnt] = t;
cnt++;
}
else{ // otherwise reset the character counter and print the received string
cnt = 0;
printf("UART Message: %c", received_string);
}
}
}