cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of HAL_PCDEx_SetTxFiFo() when using DMA

it3
Associate II

Hello,

 

I am trying to implement a Hi-Speed USB Device on STM32 baremetal project for STM32MP131Axx by using STM32Cube_FW_MP13_V1.1.0.

 

I am using the internal DMA of USB OTG to get faster the bulk transfer. I have 2 questions since I would like to know the suitable FIFO size when using the internal DMA.

 

Q1

I found the following comment in HAL_PCDEx_SetTxFiFo() function in stm32mp13xx_hal_pcd_ex.c.

When DMA is used 3n * FIFO locations should be reserved for internal DMA registers

 

I am using the endpoint 1 as bulkout that the max packet size is 512 bytes. In this case, is the comment mean that I need to pass 384 words to HAL_PCDEx_SetTxFiFo() as below?

 

HAL_PCDEx_SetTxFiFo(&hpcd,
                    1,       // Use DIEPTXF1 for endpoint 1.
                    0x180);  // 384 words = 1536 bytes

 

 

Q2

I refered the following post. Is it same for STM32MP13 line that I should not allocate more than (4096 – 72 (for DMA descs)) bytes in total -> 0x3EE words when using DMA?

https://community.st.com/t5/stm32-mcus-embedded-software/problem-with-stm32h747-hs-usb-dma/m-p/165459 

 

Best regards,

2 REPLIES 2
andy817501
Associate II

I also have a similar problem. Have you solved it? 

 
it3
Associate II

Hello,

 

I am not certain, but I follow the rules below that are related my questions above. I use the internal DMA and I do not observe any issue for now.

  1. Allocates triple the size of the packet size to FIFO.
  2. Total allocated FIFO size should be less than 0x3ee words.

 

The following code shows FIFO allocation in my program. I hope this helps.

// Rx packet sizes
//   control transfer in   64 bytes
//      bulk transfer in  512 bytes
//                 total  576 bytes
//
// Sets triple the total packet size of 1728 bytes.
// Neess to pass the 4 bytes unit value, 1728 / 4 = 432 (0x1b0).
HAL_PCDEx_SetRxFiFo(&hpcd, 0x1b0);

// Tx packet size of endpoint 0
//   control transfer out   64 bytes
//
// Sets triple the packet size of 192 bytes.
// Neess to pass the 4 bytes unit value, 192 / 4 = 48 (0x30).
HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x30);

// Tx packet size of endpoint 1
//   bulk transfer out  512 bytes
//
// Sets triple the packet size of 1536 bytes.
// Neess to pass the 4 bytes unit value, 1536 / 4 = 384 (0x180).
HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x180);

// Total allocated fifo size is 0x1b0 + 0x30 + 0x180 = 0x360 words.
// It is less than 0x3ee words.

 

 Best regards,