cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H573 CDC ACM project - cannot get device to enumerate

loz01
Associate

Hi, was wondering if someone can point me in the right direction on an issue I've been battling with regarding USB device enumeration.

I'm using Cube FW_H5_V1.4.0 > Projects > NUCLEO-H563ZI > Applications > USBX > UX_Device_HID_CDC_ACM for STM32Cube IDE as the starting point.

Closest example I could find but have had to make significant changes as I'm trying to create a bare metal version, don't want HID and of course am using a different micro on the STM32H573I-DK board.

I've got the code running and get the "USB device not recognised" popup on Windows when I connect the board. I'm hitting a breakpoint in the HAL_PCDResetCallback function but HAL_PCD_SetupStageCallback() never runs to start the first SETUP packet. I can see that bits 10 and 11 are set in the ISTR register so it seems SETUP transaction was received and endpoint 0 RX is complete.

I'm having a hard time working out exactly why, suspect endpoint 0 is not configured correctly but how to confirm and fix? Any tips/diagnosis methods most welcome, can post up any other code blocks that may be relevant.

This is what I'm doing in main.c

PCD_HandleTypeDef hpcd_USB_DRD_FS;

HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USB_PCD_Init();
MX_USBX_Device_Init();
HAL_PCD_Start(&hpcd_USB_DRD_FS);

while (1)
{
}

and in the callback function (Cube-generated code except for my call to _ux_dcd_stm32_function() )

void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
{
/* If the device is attached or configured, we need to disconnect it. */
if (_ux_system_slave -> ux_system_slave_device.ux_slave_device_state != UX_DEVICE_RESET)
{

/* Disconnect the device. */
_ux_device_stack_disconnect();
}


/* Set USB Current Speed */
switch(hpcd -> Init.speed)
{
#ifdef PCD_SPEED_HIGH
case PCD_SPEED_HIGH:

/* We are connected at high speed. */
_ux_system_slave -> ux_system_slave_speed = UX_HIGH_SPEED_DEVICE;
break;
#endif
case PCD_SPEED_FULL:

/* We are connected at full speed. */
_ux_system_slave -> ux_system_slave_speed = UX_FULL_SPEED_DEVICE;
break;

default:

/* We are connected at full speed. */
_ux_system_slave -> ux_system_slave_speed = UX_FULL_SPEED_DEVICE;
break;
}

/* Complete the device initialization. */
_ux_dcd_stm32_initialize_complete();

/* Mark the device as attached now. */
_ux_system_slave -> ux_system_slave_device.ux_slave_device_state = UX_DEVICE_ATTACHED;


if (_ux_system_slave == UX_NULL)
{
return;
}

// Notify USBX driver so it re-opens EP0 and re-arms reception. */
UX_SLAVE_DCD *dcd = &_ux_system_slave->ux_system_slave_dcd;
UX_SLAVE_ENDPOINT *ep0 = &_ux_system_slave->ux_system_slave_device.ux_slave_device_control_endpoint;

_ux_dcd_stm32_function(dcd, UX_DCD_RESET_ENDPOINT, ep0);
}

 

 

0 REPLIES 0