cancel
Showing results for 
Search instead for 
Did you mean: 

UART/USART Does not Work

akoluacik
Senior

I would like to transmit data via USART and read the data sent to computer via a terminal(I have tried Putty and Real Term so far). To that end, I activate 0693W00000NqsasQAB.pngMy USART configuration is seen as above. I also wrote the code below:

uint8_t myTxData[13] = "Hello World\r\n";
while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
 	  HAL_StatusTypeDef res = HAL_UART_Transmit(&huart1, myTxData, 13, 10);
	  if(!res) {
		  HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
		  HAL_Delay(1000);
	  }
  }

Note that I only put here inside the while loop. The other statements were generated by CubeMX.

Normally my code sends data to my pc if res is true, in other words, if it is HAL_OK, and also toggles the LED. Since it couldn't see the data in the terminal, I changed the condition in if statement, and saw that the led is toggled in each second. Therefore, I concluded that my USART channel does not work. What's the issue?

Thx for your help in advance.

16 REPLIES 16

I am using STM32F746NG Discovery board. I changed timeout to 100 as you said, and tried more different values, i.e., HAL_MAX_DELAY. But still does not work.

My RCC setting is that I enabled HSE and configured max frequency value, which 216 kHz.

gbm
Lead III

Your program runs on STM32F746, not on ST-Link CPU (STM32F103, which uses its PA2 and PA3 to connect to F746). The schematics of Discovery board shows the pins used in F746 for UART VCP connection are PA9 and PB7, which are USART1 TX and RX pins.

Anil3
Associate III

Hi @Anıl Koluaçık​ 

Try to use CDC_Transmit_FS function as you are using the COM Port

Writing "u" instead of "you" and inability of splitting the thought to sentences really is an indicator...

Thank you sooo much. This solves my problem. I have a question, how did you determine that the correct ones are PA9 and PB7? I looked at the datasheet more times but I couldn't determine it.

Datasheet, reference manual etc. are for a microcontroller. Board features are documented in board's user manual and schematic.

MHz, kHz... The units doesn't matter, do they? 😉