Functional description
图 58 shows the following functional groupings of the main interfaces to the DMA Controller block:
- DMA hardware request interface
- 8 channels
- 32 bytes FIFO per channel for source and destination
- Arbiter
- AHB master interface
- AHB slave interface
图 59 illustrates a peripheral-to-peripheral DMA transfer, where peripheral A (source) uses a hardware handshaking interface, and peripheral B (destination) uses a software handshaking interface. For example, the request to send data to peripheral B is originated by the CPU, while writing to peripheral B is handled by the DMA Controller. The channel source and destination arbitrate independently for the AHB master interface, along with other channels.
DMA Hardware Interface Assignment
Each channel can then communicate with the peripheral connected to that interface through the assigned hardware handshaking interface, the hardware handshaking interfaces are assigned as shown in 表 260. The developer can program the CFG_CHx.SRC_PER or CFG_CHx.DEST_PER to assign a handshaking interface for each channel source and destination.
CFG_CHx.DEST_PER | CFG_CHx.SRC_PER | Peripheral Name | Peripheral Description |
---|---|---|---|
0 |
M2P: any value (0 – 14) P2P: any value except 0 |
SPIM TX |
SPI Master Transmit |
P2M: any value (0 – 14) P2P: any value except 1 |
1 |
SPIM RX |
SPI Master Receive |
2 |
M2P: any value (0 – 14) P2P: any value except 2 |
SPIS TX |
SPI Slave Transmit |
P2M: any value (0 – 14) P2P: any value except 3 |
3 |
SPIS RX |
SPI Slave Receive |
4 |
M2P: any value (0 – 14) P2P: any value except 4 |
QSPI0 TX |
QSPI Master Transmit |
P2M: any value (0 – 14) P2P: any value except 5 |
5 |
QSPI0 RX |
QSPI Master Receive |
6 |
M2P: any value (0 – 14) P2P: any value except 6 |
I2C0 TX |
I2C Transmit |
P2M: any value (0 – 14) P2P: any value except 7 |
7 |
I2C0 RX |
I2C Receive |
8 |
M2P: any value (0 – 14) P2P: any value except 8 |
I2C1 TX or I2S_S TX |
I2C or I2S Slave Transmit |
P2M: any value (0 – 14) P2P: any value except 9 |
9 |
I2C1 RX or I2S_S RX |
I2C or I2S Slave Receive |
10 |
M2P: any value (0 – 14) P2P: any value except 10 |
UART0 TX |
UART Transmit |
P2M: any value (0 – 14) P2P: any value except 11 |
11 |
UART0 RX |
UART Receive |
12 |
M2P: any value (0 – 14) P2P: any value except 12 |
QSPI1 TX or I2S_M TX |
QSPI Master or I2S Master Transmit |
P2M: any value (0 – 14) P2P: any value except 13 |
13 |
QSPI1 RX or I2S_M RX |
QSPI Master or I2S Master Receive |
P2M: any value (0 – 14) P2P: any value except 14 |
14 |
SNSADC |
Sensor ADC |
DMA Setting Up Transfers
Transfer Type Flow Control
GR551x only support DMA as flow controller. There are four transfer types as follow:
- Memory to memory
- Memory to peripheral
- Peripheral to memory
- Peripheral to peripheral
Transfer Width
For memory, source transfer width must be less than or equal to AHB master interface data bus width, normally 8, 16 or 32 bits. For a non-memory, source transfer width is equal to the peripheral FIFO Width.
For memory, destination transfer width must be less than or equal to AHB master interface data bus width, normally 8, 16 or 32 bits. For a non-memory, destination transfer width is equal to the peripheral FIFO Width.
Source and Destination Address Increment
- Source address increment: indicates whether to increase or decrease the source address on every source transfer. If the device is fetching data from a source peripheral FIFO with a fixed address, then set this field to No change.
- Destination address increment: whether to increment or decrement the destination address on every source transfer. If the device is writing data to a destination peripheral FIFO with a fixed address, then set this field to No change.
Channel Priority
Each channel has a programmable priority in range 0 – 7, lowest to highest. Channel priority work for most scenario except in master bus. It is worth noting that a request for the master bus interface can be made at any time, but is granted only after the current AHB transfer (burst or single) is completed. Therefore, when the master interface is transferring data for a low priority channel while a high priority channel requests service, it completes the current AHB transfer (burst or single) for the low priority channel before switching to transfer data for the high one.
DMA Transfer
DMA has 8 channels and each channel has a 32-bit FIFO. The 8 FIFOs are independent of each other. After the DMA channel is enabled, the DMA obtains data from the source according to the bit width configured for the source port, stores the data into the DMA FIFO, takes out the data from the DMA FIFO according to the bit width configured for the destination port, and sends the data to the destination port. Regardless of the configured transmission bit width, the data obtained from the source is compactly stored, which can also maximize the use of DMA FIFO storage space. For example, the transmission bit width is 16-bit wide and the FIFO bit width is 32-bit wide, so that one depth of DMA FIFO will store two pieces of 16-bit wide data. When DMA is used as flow control, the total size of data in bytes (blk_size_bytes_dma) transmitted by DMA in a single transmission is equal to the product of the source transmission bit width (src_single_size_bytes) and the block size (BLOCK_XFE_SIZE).
Source Port Bit Width | Destination Port Bit Width | Block Size (DMA as Flow Control) | Source Content: Address/Data | Transfer Operations | Destination Content: Address/Data |
---|---|---|---|---|---|
8 | 8 | 4 | @0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
1: Read B0[7:0] @0x0 to DMA then write B0[7:0] @0x0 2: Read B1[7:0] @0x1 to DMA then write B1[7:0] @0x1 3: Read B2[7:0] @0x2 to DMA then write B2[7:0] @0x2 4: Read B3[7:0] @0x3 to DMA then write B3[7:0] @0x3 |
@0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
8 | 16 | 4 | @0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
1: Read B0[7:0] @0x0 to DMA 2: Read B1[7:0] @0x1 to DMA then write B1B0[15:0] @0x0 3: Read B2[7:0] @0x2 to DMA 4: Read B3[7:0] @0x3 to DMA then write B3B2[15:0] @0x2 |
@0x0/B1B0 @0x2/B3B2 |
8 | 32 | 4 | @0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
1: Read B0[7:0] @0x0 to DMA 2: Read B1[7:0] @0x1 to DMA 3: Read B2[7:0] @0x2 to DMA 4: Read B3[7:0] @0x3 to DMA then write B3B2B1B0[31:0] @0x0 |
@0x0/B3B2B1B0 |
16 | 8 | 2 | @0x0/B1B0 @0x2/B3B2 |
1: Read B1B0[15:0] @0x0 to DMA then write B0[7:0] @0x0 2: write B1[7:0] @0x1 3: Read B3B2[15:0] @0x2 to DMA then write B2[7:0] @0x2 4: write B3[7:0] @0x3 |
@0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
16 | 16 | 2 | @0x0/B1B0 @0x2/B3B2 |
1: Read B1B0[15:0] @0x0 to DMA then write B1B0[15:0] @0x0 2: Read B3B2[15:0] @0x2 to DMA then write B3B2[15:0] @0x2 |
@0x0/B1B0 @0x2/B3B2 |
16 | 32 | 2 | @0x0/B1B0 @0x2/B3B2 |
1: Read B1B0[15:0] @0x0 to DMA 2: Read B3B2[15:0] @0x2 to DMA then write B3B2B1B0[31:0] @0x0 |
@0x0/B3B2B1B0 |
32 | 8 | 1 | @0x0/B3B2B1B0 | 1: Read B3B2B1B0[31:0] @0x0 to DMA then write B0[7:0] @0x0 2: write B1[7:0] @0x1 3: write B2[7:0] @0x2 4: write B3[7:0] @0x3 |
@0x0/B0 @0x1/B1 @0x2/B2 @0x3/B3 |
32 | 16 | 1 | @0x0/B3B2B1B0 | 1: Read B3B2B1B0[31:0] @0x0 to DMA then write B1B0[15:0] @0x0 2: write B3B2[15:0] @0x2 |
@0x0/B1B0 @0x2/B3B2 |
32 | 32 | 1 | @0x0/B3B2B1B0 | 1: Read B3B2B1B0[31:0] @0x0 to DMA then write B3B2B1B0[31:0] @0x0 | @0x0/B3B2B1B0 |
Multi-block DMA transfer
Multi-block DMA transfers are supported through Auto-reloading.
During Auto-reloading, the channel registers are reloaded with their initial values at the completion of each block and the new values used for the new block.
Some or all of the SRC_ADDR_CHx, DEST_ADDR_CHx, and CTRL_CHx channel registers are reloaded from their initial value at the start of a block transfer.
By configuring the Configuration Register (CFG_CHx.RELOAD_SRC), you can program if the SRC_ADDR_CHx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers.
By configuring the Configuration Register (CFG_CHx.RELOAD_DST), you can program if the DEST_ADDR_CHx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers.
DMA Interrupt
The INT_RSTAT, INT_STAT, INT_MASK, INT_CLR registers are provided to manage interrupts. The INT_MASK register is used to enable or disable the block transfer complete interrupt, DMA transfer complete interrupt and error interrupt. By reading the INT_STAT registers or INT_RSTAT registers, you can check whether the interruption occurred. To clear interrupts, write 1 to the INT_CLR registers.
- INT_MASK registers: enable or disable the block transfer complete interrupt, DMA transfer complete interrupt and error interrupt.
- INT_STAT or INT_RSTAT registers: reply whether the interruption occurred.
- INT_CLR registers: write 1 to INT_CLR to clear interrupts.