cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767ZI and USART by HAL.

Lagodolio
Senior

Hello,

I have a strange problem with my STM32F767 ZI and USART communication.

With CubeMX, I set USART2->Asyncronous, SYS->Debug Serial Wire and RCC-> HSE Active (crystal/ceramic resonator).

So I generated a project for Atollic Truestudio and inserted

HAL_Delay(500);
  while (1)
     {
       /* USER CODE END WHILE */
       /* USER CODE BEGIN 3 */
      
        HAL_UART_Transmit(&huart2,"Hello",5,1000);
 
    //Toggle On board LEDSs, for testing...
       HAL_GPIO_TogglePin(led2_GPIO_Port,led2_Pin);
       HAL_Delay(500);
 
       HAL_GPIO_TogglePin(led3_GPIO_Port,led3_Pin);
       HAL_Delay(500);
    }
 
 /* USER CODE END 3 */

After compiling (without errors) and resetting, program runs correctly (on board LEDs swith on/off) but no message to my terminal.

I connect my Nucleo to CN1 (ST-link USB port) as I do with my F4, but without success.

Serial config is OK.

Any suggest?

Thanks and best regards

4 REPLIES 4
AvaTar
Lead

How about working backwards ?

Next thing would be to check if there is a signal on the TX lines while sending - on both ends.

If not, the init code is probably not correct.

Lagodolio
Senior

The code is quite simple, generated by CubeMX plus few lines - at first it was simply:

HAL_Delay(500);
  while (1)
     {
       /* USER CODE END WHILE */
       /* USER CODE BEGIN 3 */
      
        HAL_UART_Transmit(&huart2,"Hello",5,1000);
 
    }
 
 /* USER CODE END 3 */

With my STM32F446RE I haven't problems, but with F7s it doesn't work...

Is it possible there is a different approach to USB communication (F446RE has a single USB port)?

I generally use STlink USB port as a VirtualCOM and it works well (tested with speed from 9600 to 460800). As terminal I use TeraTERM, Putty and Arduino Serial Monitor.

In Debug mode, HAL_UART_Transmit instruction is processed but nothing appears on TeraTerm windows.

CubeMX set the typical stm32 PA2(TX) and PA3(RX), but F767ZI pinout doesn't refer PA2 as UART pin on CN12...

Lagodolio
Senior

ops... the last part of my message was cut off...

If I connect a Logic Analizer on TX pin-CN5 (ST-Link "half board") no signal is recorded, so AvaTar is right, there is a init problem. Is it possible that ST-link TX pin isn't PA2 and I didn't understand STM schematics?

Thanks, AvaTar, for your help!

Lagodolio
Senior

News about HAL_UART_Transmit(): if I connect a serial-to-USB device (a cheap SiliconLabs CP210x) to UART2 TX pin, I can view my message on terminal. So the problem isn't HAL function but it is the communication (or link) between UART2 (or UART3?) to USB CN1.

I can see "ST link Virtual Port" as in my F4, but (probably) I cannot initialize my code to use it....