Problems with ST32F302 and USB

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problems with ST32F302 and USB

Post 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
gab
Posts: 17
Joined: Wed Sep 23, 2020 1:05 pm
Been thanked: 1 time

Re: Problems with ST32F302 and USB

Post by gab »

Strange, but default_handler() never called... :?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problems with ST32F302 and USB

Post 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
gab
Posts: 17
Joined: Wed Sep 23, 2020 1:05 pm
Been thanked: 1 time

Re: Problems with ST32F302 and USB

Post by gab »

If i configure AF to 0, function usb_event() not called.
gab
Posts: 17
Joined: Wed Sep 23, 2020 1:05 pm
Been thanked: 1 time

Re: Problems with ST32F302 and USB

Post 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);
gab
Posts: 17
Joined: Wed Sep 23, 2020 1:05 pm
Been thanked: 1 time

Re: Problems with ST32F302 and USB

Post by gab »

Promlem solved!

in board.h _must_ be line:
#define STM32F302xC

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