Skip to main content
Associate III
April 2, 2024
Question

Please let me know how to use CDC (USB device) with STM503RB to open Com port

Hi,

I'm trying to set up the CDC  with my H053RB board. and I found a guide on following link.

https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274

But I realized there was issue about HardFault_Handler. it happened all the time even though I commented  out the ICACHE line as below.

MX_GPIO_Init();

//MX_ICACHE_Init();

MX_USART1_UART_Init();

MX_USART3_UART_Init();

MX_USB_PCD_Init();

/* USER CODE BEGIN 2 */

while(hUsbDeviceFS.pClassData == NULL);

//HAL_Delay(8); // Minimum needed delay

MX_ICACHE_Init();

/* USER CODE END 2 */

 

/* Infinite loop */

I'm wondering if there are any workaround for this issue. 

Thanks,

Luke.

 

This topic has been closed for replies.

3 replies

STTwo-32
ST Technical Moderator
April 2, 2024

Hello @LukeJang522 

I suggest you to take a look at this example. It should be helpful.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate III
April 3, 2024

STTwo-32,

Thank you for your reply. 

I'm trying to generate the code that you sent the link, but there's errors. 

1. there is no tx_api.h file.

app_threadx.h

/* Includes ------------------------------------------------------------------*/

#include "tx_api.h"

2. even I copy the file forcibly, there are another errors as below

In file included from ../Core/Src/app_threadx.c:22:

../Core/Inc/app_threadx.h:64:1: error: unknown type name 'UINT'

64 | UINT App_ThreadX_Init(VOID *memory_ptr);

| ^~~~

../Core/Inc/app_threadx.h:64:23: error: unknown type name 'VOID'

64 | UINT App_ThreadX_Init(VOID *memory_ptr);

| ^~~~

../Core/Src/app_threadx.c:59:1: error: unknown type name 'UINT'

59 | UINT App_ThreadX_Init(VOID *memory_ptr)

| ^~~~

../Core/Src/app_threadx.c:59:23: error: unknown type name 'VOID'

59 | UINT App_ThreadX_Init(VOID *memory_ptr)

3. It seems like I can't just use the code, it might needs something else. 

I wasn't also able to generate the code by UX_Device_CDC_ACM.ioc file. 

I'm not sure there is another example or not. Could you please help me to fix it?

 

Thanks.