DMA Buffer Count - KBA218339

Version: **

 

Question:

How many DMA buffers can be allocated? What is the total size of DMA buffers that can be allocated? 

 

Answer:

DMA channels require two resources: 

  1. DMA buffers
  2. DMA descriptors

The number of DMA buffers is not fixed and depends on the size of the buffers being allocated; the number of DMA descriptors is fixed to a maximum of 510.

The CyU3PDebugInit() function creates an internal DMA channel that uses 2 KB of buffering and nine DMA descriptors.

The CyU3PUSbStart() function creates two internal DMA channels that use a total of 1 KB of buffering and six DMA descriptors. 

When an AUTO channel with N buffers of S bytes each is created, it requires N × S bytes of buffering and N + 1 DMA descriptors. This is why an AUTO channel creation fails when N > 494.

When a MANUAL channel with N buffers of S bytes each is created, it requires N × S bytes of buffering and 4N + 1 DMA descriptors. This is why a MANUAL channel creation fails when N > 123.

The DMA buffer space available in FX3 with 512 KB SRAM (CYUSB3013 and CYUSB3014) is 224 KB. An additional 32 KB reserved for second-stage bootloader can be used by setting the CY_U3P_SYS_MEM_TOP macro to 0x40080000 in the cyfxtx.c file. 

In FX3 with 256 KB SRAM (CYUSB3011 and CYUSB3012), the DMA buffer space available is 32 KB. An additional 32 KB reserved for second-stage bootloader can be used by setting the CY_U3P_SYS_MEM_TOP macro to 0x40040000 in the cyfxtx.c file.

The default memory map used for FX3 applications is provided in the fx3_512k.ld (for 512 KB SRAM) and fx3_256k.ld (for 256 KB SRAM) files available in the following path: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\fw_build\fx3_fw

When the total size of DMA buffers allocated in the firmware exceeds the limit, CY_U3P_ERROR_MEMORY_ERROR (error code: 0x10) is generated.