Showing results for 
Search instead for 
Did you mean: 

How to send USB Host 512 bytes long data using STM32U575

Associate III

Dear All,

I am developing an application for USB host mass storage class for STM32U575.

I am using STM32HAL APIs for developing USB host and using TinyUSB open-source USB stack.

I am able to enumerate flash drive successfully, but not able to perform some of the file operations.

I am facing below issue.

while sending the command for file sync for FAT32 file system.

My code hits below statement in the code, here "hc->xfer_len" is 512 bytes and this makes len_words = 128.


The highlighted if statement gets true and due to that NPTXFEM, interrupt is getting enabled.

As soon as the interrupt is enabled we are continuesly getting NPTXFEM interrupt and code gets hang in HAL_HCD_IRQHandler(),

In stm32u5xx_hal_hcd.c file this interrupt is not handled.

Could some one please help me in understanding how to handle this interrupt? and what should be the ideal size for bulk endpoints?


Thanks in advance!

Associate III


Any one from ST can respond to my query?

Associate III

could someone please respond to my query?

Pavel A.
Evangelist II

The snippet that you're quoting is here in function USB_HC_StartXfer() , correct? 

Is it called in context when the USB interrupts are enabled ?


Associate III

Hi @Pavel A. 

Thanks for the response.

1. Yes, correct the snippet is from USB_HC_StartXfer().

2. Yes interrupts are enabled while calling that function.

Try to disable interrupts (at least the USB interrupt) around calling USB_HC_StartXfer.

Associate III

Thank you very much for the response @Pavel A. 

But my query was related to NPTXFEM interrupt which is getting enabled whenever we are trying to write data more than the space available in non-periodic transmit FIFO, and it generates NPTXFE interrupt which is currently not handled in stm32 HAL library (HAL_HCD_IRQHandler).

Also As per data sheet of STM32U575 max size for DIEPTXF0_HNPTXFSIZ (Non periodic transmit FIFO) is 512 bytes, but HAL library allocates only for 128 bytes in USB_HostInit().


Could you please let me know how to handle that interrupt?

Pavel A.
Evangelist II

but HAL library allocates only for 128 bytes in USB_HostInit().

Is the USB working in full speed or high speed mode? If FS, there's no way to send a 512 byte packet.

The software can send more than the endpoint size (which is limited by the mode, either FS or HS ), then the interrupt handler should automatically forward the used data pointer and send the next portion. If this does not work, please report a bug.

Again, try to disable USB (or global) interrupts around the USB TX function calls, so that it is executed uninterrupted. There were reports that it helps for other STM32 models.