2021-01-18 06:26 PM
I am using a STM32F429I-Disc1 board and configured my project as follows:
USB_OT_FS:
USB_DEVICE (middleware):
All parameter settings are default and nothing has been changed. I also increased the minimum heap and stack size for the project :
Clock config:
What Im trying to achieve is just sending simple data over the VCOM port.
The while loop:
while (1)
{
// usbBuffer is now just a simple buffer containing "Hello World" for debugging
// (declared outside scope)
CDC_Transmit_FS(usbBuffer, strlen((char *)usbBuffer));
// Toggle LED for debugging
HAL_GPIO_TogglePin(GPIOG, GPIO_PIN_13);
HAL_Delay(500);
}
I debugged the "MX_USB_DEVICE_Init" function that cubeMX generated (and gets called before the while loop) and everything seems to initialize normally. (no error handlers being called, timeouts etc.)
The project compiles without any errors or warnings and when flashing on the board nothing out of the ordinary happens when debugging:
However when look for my board in Windows Device Manager it is nowhere to be found:
Only the STLink debugger VCOM is detected and I am running out of options here.
What I have tried so far:
Hopefully someone knows what I have overlooked here. All help is appreciated, thanks in advance.
2021-01-18 07:13 PM
Put a delay after initialization and before you call CDC_Transmit_FS for the first time. The PC needs time to initialize the peripheral which triggers some other initialization within the USB stuff. The HAL USB driver is not particularly robust.
2021-01-19 07:18 AM
Thanks for the quick reply,
I put a delay of 30000ms after the usb initialization:
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t usbBuffer[20] = "Hello World \r\n";
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI5_Init();
MX_USB_DEVICE_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
HAL_Delay(30000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
CDC_Transmit_FS(usbBuffer, strlen((char *)usbBuffer));
HAL_GPIO_TogglePin(GPIOG, LED_GREEN_Pin);
HAL_Delay(1000);
}
/* USER CODE END 3 */
}
Unfortunately Windows still does not see a second Virtual Com Port except for the standard STLink debugger.
I have seen on different forums that people with this particular board have the same troubles I am experiencing (Windows 10 not recognizing the port).
Maybe the problem lies somewhere else?
2021-01-19 07:23 AM