cancel
Showing results for 
Search instead for 
Did you mean: 

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

LukeJang522
Associate III

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.

 

3 REPLIES 3
STTwo-32
ST Employee

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.

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.

 

Hi @STTwo-32 

I tried duplicating the code from the the link 

https://github.com/STMicroelectronics/STM32CubeH5/tree/main/Projects/NUCLEO-H503RB/Applications/USBX/Ux_Device_CDC_ACM

 

Bt i seems that it  never calls "entry function tx_application_define()". i've also chagne the "tx_initialize_low_level.S"

/* Set base of available memory to end of non-initialised RAM area. */

#ifdef USE_DYNAMIC_MEMORY_ALLOCATION

LDR r0, =_tx_initialize_unused_memory // Build address of unused memory pointer

//LDR r1, =Image$$RW_IRAM1$$ZI$$Limit // Build first free address

LDR r1, =|Image$$RW_IRAM1$$ZI$$Limit|

ADD r1, r1, #4 //

STR r1, [r0] // Setup first unused memory pointer

#endif

Even I tried to connect USB to CN3. 

Did I miss anything?

 

Thanks,