Skip to main content
Visitor II
May 19, 2025
Question

STM32H743 USB device transmits zeros to the Host

  • May 19, 2025
  • 2 replies
  • 457 views

Everything else is working fine.

Setup packet with SET_ADDRESS received and processed.

Next GET_DESCRIPTOR for DEVICE which is sent back ok 

I've verified the data written to the Tx FIFO is correct.

Correct number of bytes it transmitted but the bytes are not correct.

I'm using a STM32H743-EVAL board, hardware is working fine

Any suggestions?

p.s. the Device Descriptor received displayed by USB View

usb-view-cap1.png

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    May 19, 2025

    Hi @lw23 

    Would you double-check the device descriptor data you are writing to the Tx FIFO. Ensure that all fields are correctly populated according to the USB specification. The bLength field should be 18 for a standard device descriptor.

    Super User
    May 19, 2025

    Is data cache enabled? Disable it during the debugging stage. If that fixes it, you'll need to instrument your code with appropriate cache handling.

    > I've verified the data written to the Tx FIFO is correct.

    How, exactly?

    lw23Author
    Visitor II
    May 20, 2025

    I'm not using DMA, PIO only

     

    void USB_WritePacket(USB_OTG_GlobalTypeDef *USBx,uint8_t *src, 
    uint8_t ch_ep_num,uint16_t len)

    {

    uint32_t USBx_BASE = (uint32_t)USBx;
    uint8_t *psrc=src;
    uint32_t count32b;
    uint32_t i;
    uint32_t data;

    count32b = ((uint32_t)len + 3U) / 4U;
    for (i = 0U; i < count32b; i++)
    {
    data = __UNALIGNED_UINT32_READ(pSrc);

    printf("%08X\n",data);


    USBx_DFIFO((uint32_t)ch_ep_num) = data;

    pSrc++;
    pSrc++;
    pSrc++;
    pSrc++;
    }

    return;
    }


    Produces this output

    OTG_FS: DIEPTSIZ = 0x00080012
    OTG_FS: DTXFSTS = 0x00000020
    OTG_FS: 02000112
    OTG_FS: 40000002
    OTG_FS: 00190957
    OTG_FS: 02010100
    OTG_FS: 00000103
    OTG_FS: DIEPTSIZ = 0x00080000
    OTG_FS: DTXFSTS = 0x0000001B

    XFRSIZ is correctly decremented to zero

    FIFO space reduced by 5 words

     Thanks for the speed replies, I really appreciate it