Enabling the UCPD DMA
Hello. I'm using an STM32G071KBU6N in a USBPD application. My application uses both internal UCPD ports.
I'm working on enabling the DMA and DMAMUX for use with the UCPD peripheral, for both Rx and Tx of both ports. I'm focusing on Tx right now, and can't seem to get it to work.
The reference manual has a great section "Use of DMA for Transmission" in section 38.4.11. I have the TXDMAEN bit set in the UCPD_CR register. I have the whole message programmed in memory. Right now, it's a dummy message consisting of two header bytes plus one data object consisting of four bytes, for a total of six bytes.
My DMAMUX is setup with the following register values:
DMAMUX_C0CR = 0x3A (DMAREQ_ID = UCPD1_RX)
DMAMUX_C1CR = 0x3B (DMAREQ_ID = UCPD1_TX)
DMAMUX_C2CR = 0x3C (DMAREQ_ID = UCPD2_RX)
DMAMUX_C3CR = 0x3D (DMAREQ_ID = UCPD2_TX)
No other DMAMUX registers have anything other than zeroes in them.
I setup DMA properly. For the UCPD1_TX channel, I setup:
DMA_CCR2 = 0x92
DMA_CNDTR2 = 0x6 (6 bytes)
DMA_CPAR2 = 0x4000A024 (The address of the UCPD1_TXDR register)
DMA_CMAR2 = The address of the memory for the data array
DMA_ISR = DMA_IFCR = 0
After that is setup I enable the DMA by setting the DMA_CCR2.EN bit to 1 (register = 0x93).
I write TXSEND to initiate the message transfer. However, the entire message isn't sent. I have to continually write TXSEND until the DMA buffer is empty (DMA_CNDTR2 = 0), which tells me the DMA is not implemented correctly.
Can someone let me know what step I am missing? I think the DMAMUX is not setup properly, but I'm unfamiliar with that peripheral and how to set it up. Ideally I would like to write TXSEND once, and my entire data is sent via DMA out the UCPD peripheral.
Thanks,
Rob
