cancel
Showing results for 
Search instead for 
Did you mean: 

UART communication problem

bakhti
Associate II

hi i'm trying to use the stm32H750 uart with Interrupt i managed to get it working but the message is a bit off ( alot ) here is a bit of the code

uint8_t tx_buff[]="                                                                      ";
uint8_t rx_buff[20];
  HAL_UART_Receive_IT(&huart1, &rx_buff[0], 20);
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
n3=n3+5;
HAL_UART_Receive_IT(huart, &rx_buff[0], 20);
check = rx_buff[0];
if (check==67){
	n1=n1+100;
};
HAL_UART_Transmit_IT(&huart1, rx_buff, 21);
 
}

what i'm doing to try it , is that i'm monitoring via stmstudio and whenever a message arrive i'll rederect to the the host and read it again

here are the results

0693W000004I4DpQAK.png

rx is coming back from mcu

11 REPLIES 11

See what it is directly after reset. That's probably the correct value. You could also check the datasheet and reference manual.

If you feel a post has answered your question, please click "Accept as Solution".

Ok, then try some simple echoing...

Like

while(1)
{
  if((USART1->ISR & USART_ISR_RXNE) == 0) // Wait for Char
  {
    if (USART1->ISR & USART_ISR_ORE) // Overrun Error
      USART1->ICR = USART_ICR_ORECF;
    if (USART1->ISR & USART_ISR_NE) // Noise Error
      USART1->ICR = USART_ICR_NCF;
    if (USART1->ISR & USART_ISR_FE) // Framing Error
      USART1->ICR = USART_ICR_FECF;
  }
  else // RXNE flagged
  {
    uint16_t data = USART1->RDR; // Read Char
    while((USART1->ISR & USART_ISR_TXE) == 0); // Wait for Empty
    USART1->TDR = data; // Send Char
  }
} // sourcer32@gmail.com

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..