Page 2 of 2

Re: Problems with ST32F302 and USB

Posted: Wed Sep 23, 2020 7:51 pm
by Giovanni
Hi,

I should have been more specific :)

In the module hal_usb.c, there is a default_handler() function, it decodes all standard messages, you should verify if it gets in that function and which messages are processed in there, if any (I suspect none).

The problem is that the two things that can cause that are clocks and GPIO setup and you already verified that.

Could you try the F3 USB demo as-is by just making the minimum of changes? (STM32-USB-CDC) the problem must be in those changes.

Giovanni

Re: Problems with ST32F302 and USB

Posted: Wed Sep 23, 2020 8:08 pm
by gab
Strange, but default_handler() never called... :?

Re: Problems with ST32F302 and USB

Posted: Wed Sep 23, 2020 8:17 pm
by Giovanni
It is because the device never receives a message from the host.

Check the datasheet, unlike the F303, the F302 does not have an alternate function for USB (if I am reading it right), the pins should probably be left as input (or analog).

Giovanni

Re: Problems with ST32F302 and USB

Posted: Thu Sep 24, 2020 8:30 am
by gab
If i configure AF to 0, function usb_event() not called.

Re: Problems with ST32F302 and USB

Posted: Thu Sep 24, 2020 8:57 am
by gab
I try create simple project in MXCube. Generated USB init code:
/**USB GPIO Configuration
PA11 ------> USB_DM
PA12 ------> USB_DP
*/
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF14_USB;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Re: Problems with ST32F302 and USB

Posted: Thu Sep 24, 2020 11:03 am
by gab
Promlem solved!

in board.h _must_ be line:
#define STM32F302xC

for this chip:
Info : device id = 0x10036422
Info : flash size = 128kbytes