cancel
Showing results for 
Search instead for 
Did you mean: 

Can't stablish a UART communication with B-U585I-IOT02A

PGalieta
Associate

Dear all,

I've just bought a B-U585I-IOT02A board which has STM32U585 embedded. So far I was able to run blink examples just fine, but there's no way I can stablish a UART communication with a serial monitor on my PC. Here's what I've tried to transmit a "Hello world" from board to pc:

  1. Created the project using CubeMX 6.4.0 , HAL U5 1.0.2, STM CubeIDE 1.8.0.
  2. Enabled USART (tried both 1 and 2) with: GPIO No pull up and no pulldown, GPIO Pull up, Maximun output speed low and Baud rate 9600, Maximum output speed high and Baud rate 115200. For all this cases, words were set 8 bits, no parity, 1 stop bit.
  3. In main.c, HAL_UART_Transmit(), HAL_UART_Transmit_IT(), HAL_UART_Transmit_DMA() were used without success.

FWIW, I'm programming the board through embedded ST-Link using USB and expecting the UART on the same port. According to user manual UM2839, there should be a virtual COM over the USB interface connected to USART1. Also, I have a Nucleo F446-RE which I can use to develop this task following the same steps, so it's not a problem with the serial monitor.

Here's my last version of the code. I can debug stepping over and no Error Handler is triggered:

/* Includes ------------------------------------------------------------------*/
#include "main.h"
 
UART_HandleTypeDef huart1;
 
/* USER CODE BEGIN PV */
uint8_t message[13] = "Hello world\r\n";
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ICACHE_Init(void);
static void MX_USART1_UART_Init(void);
 
int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
  HAL_PWREx_EnableVddIO2();
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ICACHE_Init();
  MX_USART1_UART_Init();
 
  /* Infinite loop */
  while (1)
  {
 
	if(HAL_UART_Transmit(&huart1, (uint8_t *)message, 13, 100) != HAL_OK)
	{
		Error_Handler();
	}
	HAL_Delay(1000);
  }
}
 
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
  /** Configure the main internal regulator output voltage
  */
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE4) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_4;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
                              |RCC_CLOCKTYPE_PCLK3;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1;
 
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
  __HAL_RCC_PWR_CLK_DISABLE();
}
 
static void MX_ICACHE_Init(void)
{
 
 
  /** Enable instruction cache in 1-way (direct mapped cache)
  */
  if (HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_ICACHE_Enable() != HAL_OK)
  {
    Error_Handler();
  }
}
 
static void MX_USART1_UART_Init(void)
{
 
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_ENABLE;
  huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
 
}
 
static void MX_GPIO_Init(void)
{
 
  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOG_CLK_ENABLE();
 
}
 
void Error_Handler(void)
{
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
}
 
#ifdef  USE_FULL_ASSERT
 
void assert_failed(uint8_t *file, uint32_t line)
{
 
}
#endif 
 

2 REPLIES 2
Sara BEN HADJ YAHYA
ST Employee

Hello @PGalieta​ ,

Thanks for your feedback,

Could you please share your .ioc file and specify the CubeMX version??

Regards,

Sara.

MFran.4
Senior

ST-LINK Programming port and Virtual com port should be different. Check your device manager under "Ports" or similar.