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
TDK
Guru

Seems like the clock is off. Check your clock settings including HSITRIM which CubeMX has a history of getting incorrect. Could also be that you're using incompatible UART settings.

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

Baud rates probably off, get a scope, check the timings and settings you're pushing in.

Does a simple one-at-a-time polling method work? How about sending?

Why does the transmit send 21 characters?

I'd probably copy the rx_buff to tx_buff before recommitting the rx_buff

H7 doesn't output at RS232 levels

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

-baudrate is set on 9600 on both the emitter(pc) receiver(stm32)

-reading one time is not working either

 while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	  HAL_UART_Receive(&huart1, rx_buff, sizeof(rx_buff), HAL_MAX_DELAY);
	  HAL_Delay(500);
	  HAL_UART_Transmit(&huart1, rx_buff, sizeof(rx_buff), HAL_MAX_DELAY);
	  HAL_Delay(500);
  }

0693W000004I9F7QAK.png

0693W000004I9F7QAK.png

-just for testing i had a problem where the receive function didn't start from the 0

bakhti
Associate II

where does one find that

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

Prove that the output works, if that doesn't function there is no hope for reception.

while (1)

{

 char str[] = "UUUUU testing *****\r\n";

 HAL_UART_Transmit(&huart1, str, sizeof(str)-1, HAL_MAX_DELAY);

 HAL_Delay(500);

}

I suspect the UART connectivity is broken, but would need to understand schematic/connectivity you have wired.

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

0693W000004ILUTQA4.png

  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

what should i change it to

0693W000004ILuWQAW.jpg

works too with arduino serial