Skip to main content
Graduate
April 22, 2024
Solved

STM32G0B and USB Custom HID

  • April 22, 2024
  • 1 reply
  • 1228 views

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.
    Best answer by Peaga

    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!

    1 reply

    PeagaAuthor
    Graduate
    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?

    PeagaAuthorAnswer
    Graduate
    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!