2025-04-06 11:02 AM - last edited on 2025-04-08 7:49 AM by mƎALLEm
Hello Everyone
So I'm using a custom made STM32 board having STM32F103C8T6 MCU and after debugging the board using ST Link V2 when I try view the output through USB on my pc using the virtual COM Port and it is not working. As well as I have tried to view the output on the debugger console but it is showing temporary breakpoint for HAL_Init() . If their is any other way to view the output I would love to try and also the drivers I have install from STM32 website are for Win 7,8 versions and when I am connecting my board to my PC and opened the device manager to check the COM Port, in their under Universal Serial BUS Controller it is showing as a Unknown Device with a yellow caution sign. Do i need to have the latest drivers to view the output on Serial Wire mode?? and where can I find the latest driver for Win 11. I have attached the Pin configuration of my board and the code I am using below such that it can help you to understand the problem I am going through. Please guide me through the issue such that I can solve this problem. Also if possible please guide me through how to view the output such as simple Hello World print using the UART or any other possible way to see the output.
Thank you for your support.
Best Regards
Ratul
2025-04-08 8:08 AM
This got confused with your other thread about using the UART:
USB is much more complex that a UART - so you really should complete getting the UART working first.
This also makes it a much stronger recommendation that you start on a genuine ST Dev Board - rather than unknown custom hardware.
Some points from the other thread:
Please re-post the code using the </> button.
Tell us what debugging you've done.
Does your project
Have you done Basic USB connectivity tests:
On implementing USB within an STM32:
Application Note AN4879, Introduction to USB hardware and PCB guidelines using STM32 MCUs:
Also AN2586, Getting started with STM32F10xxx hardware development:
ST Wiki - Introduction to USB with STM32
2025-04-09 3:34 AM
@Andrew Neil Thank you for your concern.
So I will be answering your you question
So I have attached the screen shoots to support my answer.
So this is the that I'm using for my STM32 Custom board. Please look into this any if any changes required let me know and also if their is any way round I would love to try that.
#include "main.h"
#include "stdint.h"
#include "usb_device.h"
#include "usbd_cdc_if.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USB_DEVICE_Init();
HAL_Delay(1000);
uint8_t msg[] = "Hello, World from STM32 via USB CDC!\r\n";
CDC_Transmit_FS(msg, sizeof(msg) - 1);
while (1)
{
}
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
}
static void MX_GPIO_Init(void)
{
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
}
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t *file, uint32_t line)
{
}
#endif /* USE_FULL_ASSERT */
Regards
Ratul
2025-04-09 3:57 AM
@Ratul99 wrote:So this is the that I'm using for my STM32 Custom board.
Again, start off with a genuine ST board - get the software working on known-good hardware first.
Once you have it working on known-good hardware, then you can move on to debugging your custom hardware.
@Ratul99 wrote:So I have attached the screen shoots to support my answer.
Thanks. It would be nice to crop the images to just show the pertinent details - rather than the entire screen.
@Ratul99 wrote:
- It was showing as Unknown USB Device ( Device Descriptor request Failed).
So look into why your code is failing to give a valid Device Descriptor ...