Skip to main content
Visitor II
December 24, 2020
Question

I'm having an issue with USB TX/RX composite USB device STM32G473

  • December 24, 2020
  • 3 replies
  • 1124 views

So, for a project, I needed a CDC and MIDI composite device. So after some research and learning, I based my code around the CubeMX generated CDC example.

I then modified the descriptors accordingly, created functions for transmitting and receiving on those specific EPs, and life was good. Until I ran into an issue where if I attempted to transmit more than 6 MIDI messages (4 bytes each), it would transmit garbage, and then all future transmissions on that EP were also garbage.

After some digging, I realized that I never configured the PMA for my IN/OUT endpoints for the MIDI interface (I'm using 0x83 and 0x3).

So I'm unsure of why it was working with small data packets in the first place, and also how to get it working. I've done a lot of digging and trawling through the reference manuals for the STM32G4 and can't quite wrap my head around why it's not working. I tried configuring the PMA address's based on the existing offsets, but now it doesn't work even with low data quantities.

#define MIDI_IN_EP						0x83U		// EP1 for data IN
#define MIDI_OUT_EP						0x03U		// EP2 for data OUT
.
.
.
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , MIDI_IN_EP , PCD_SNG_BUF, 0xc0);
 HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , MIDI_OUT_EP , PCD_SNG_BUF, 0x190);

Can someone help me out with what I'm missing?

    This topic has been closed for replies.

    3 replies

    Visitor II
    December 24, 2020

    Hello,

    Did you set hardware fifo for new EPs? (In function "USBD_LL_Init", by using "HAL_PCDEx_SetTxFiFo")

    SSpenAuthor
    Visitor II
    December 24, 2020

    I was under the impression that this part uses the PMA as the buffer rather than a FiFo buffer. None of the other endpoints generated by CubeMX have FiFo configuration calls.

    SSpenAuthor
    Visitor II
    December 28, 2020

    Anyone have any other thoughts? There's no SetTxFiFo call found in the LL_Init function for the CubeMX generated Endpoints. Only PMA