Skip to main content
Senior
April 22, 2024
Solved

STM32G0B and USB Custom HID

Hello guys!

I'm using USB custom HID on STM32G0B for an application alike the mouse demo on "STM32G0C1E-EV" HAL package. But instead a button sending the Report, a PC software sends a 64 bytes Report to get another 64 bytes as answer.

In fact, this same code worked flawless on STM32H750 but on G0, I'm always getting a "loopback" answer after "USBD_HID_SendReport()" function, with some garbage bytes. I'm suspicious of the "USB_WritePMA" function, as it put a byte pointer to word buffer...

Do you guys have any tip about this?

Thanks again!

This topic has been closed for replies.
PeagaBest answer
Senior
April 23, 2024

It turns out that I didn't set the PMA for OUT endpoint... So on "USBD_LL_Init" function, I must add a "HAL_PCDEx_PMAConfig" for address 0x01. Now it's working fine!

Thanks!

2 replies

PeagaAuthor
Senior
April 22, 2024

It looks like the "USB_WritePMA" is ok... The problem happens when the "USBD_HID_SendReport" function is inside of "USBD_HID_DataOut" routine, where I verify if the data received by PC is ok and then, send the response... But why?

PeagaAuthorBest answer
Senior
April 23, 2024

It turns out that I didn't set the PMA for OUT endpoint... So on "USBD_LL_Init" function, I must add a "HAL_PCDEx_PMAConfig" for address 0x01. Now it's working fine!

Thanks!