SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
A DMA transfer block consists of a number of frames (FN). Each frame consists of a number of elements (EN), and each element can have a size of 8, 16, or 32 bits (ES), as follows:
transfer block size = FN × EN × ES
The FN, EN, and ES are common for the source and destination. However, the way in which the data is represented (addressing profile/mode) is independently programmable for the source and destination devices, using one of these four addressing modes:
The ES, EI, and FI values are expressed in bytes. The EI and FI values can be positive or negative.
When calculating the EI and FI values, it is critical to note that, after an element is accessed, the logical channel address pointer equals the address of the last byte (highest address) of the accessed element. The correct value for the EI or FI must be such that, when added to the logical channel address pointer, it results in the address of the first byte (lowest address) of the next element to be accessed.
The EI and FI values must be configured so that the address of each element in the transfer is aligned on an ES boundary.
Consequently, the single-index addressing mode with EI = 1 or double-index addressing mode with EI = 1 and FI = 1 is equivalent to post-increment addressing.
The source and destination start addresses must also be aligned on an ES boundary.
When the address of an element to be accessed is not aligned on an ES boundary, the transfer is stopped and a misaligned address error interrupt occurs, if enabled (see Section 16.1.4.2.1, Interrupt Generation).
The DMA4_CFNi register configures the FN in a block.
The DMA4_CENi register configures the EN.
The DMA4_CSDPi register configures the ES.
The DMA4_CSSAi and DMA4_CDSAi registers configure the source and destination start addresses.
The DMA4_CCRi register configures the source and destination addressing modes.
The DMA4_CSEIi, DMA4_CSFIi, DMA4_CDEIi, and DMA4_CDFIi registers configure the source EI, source FI, destination EI, and destination FI, respectively.
The addressing profiles are expressed as equations as follows:
Equation 1. | Constant addressing: | |||
A(n + 1) = A(n)
Note: Constant addressing mode with DMA4 to/from DDR memory is not supported on the device. To fill the DDR memory with a single value, the constant fill feature of the DMA4 must be used, instead of a constant-addressing mode transfer. | ||||
Equation 2. | Post-increment addressing: | |||
A(n + 1) = A(n) + ES | ||||
Equation 3. | Single-indexed addressing: | |||
A(n + 1) = A(n) + ES + (EI 1) | ||||
Equation 4. | Double-indexed addressing: | |||
When not at the end of a frame or transfer (that is, when the element counter ≠ 0): | ||||
A(n + 1) = A(n) + ES + (EI 1) | ||||
When at the end of a frame but not at the end of the transfer (that is, when the element counter = 0 and the frame counter ≠ 0): | ||||
A(n + 1) = A(n) + ES + (FI 1) | ||||
Calculate the element and frame index as follows: | ||||
Equation 5. | EIement index | |||
EI = [(Stride EI 1) * ES] + 1 | ||||
Equation 6. | Frame index | |||
FI = [(Stride FI 1) * ES] + 1 | ||||
where: | ||||
A(n): Byte address of the element n within the transfer. | ||||
ES is in bytes, ES{1, 2, 4}. | ||||
EI is in bytes, specified in a configuration register, 32768 EI 32767. | ||||
Stride EI: The difference in the number of elements between the start of the current element n to the start of next element, n+1. | ||||
Element counter: A counter that is (re)initiated with the number of elements per frame or per transfer. Decreased by 1 for each element transferred. The initial value is configured in the register DMA channel element number, DMA4_CENi. | ||||
FI is in bytes, specified in a configuration register, 2147483648 FI 2147483647. | ||||
Stride FI: The difference in the number of elements between the start of the last element of the current frame and the beginning of the first element of the next frame. | ||||
Frame counter: A counter that is (re)initiated with the FN per transfer. Decreased by 1 for each frame transferred. The initial value is configured in the register DMA channel frame number, DMA4_CFNi. | ||||
Figure 16-6 shows how a stride EI and FI are defined. When handling complex configurations, using strides can make it easier to calculate EI and FI because you can calculate in elements instead of bytes. (This approach is used in the 90-degree clockwise image rotation example shown in Figure 16-10.) The double-index addressing example shown in Figure 16-6 uses ES = 4, EN = 2, EI = 5, FI = 5, and FN = 2.
Figure 16-6 through Figure 16-9 show examples of addressing mode configurations. Table 16-10 lists parameter values for the examples.
Parameter | Example (a) | Example (b) | Example (c) |
---|---|---|---|
Addressing mode | Single index (or post-increment) | Double index | Double index |
Start address | 0 | 0 | 8 |
ES | 4 (32-bit) | 4 (32-bit) | 2 (16-bit) |
EN | 3 | 2 | 2 |
EI | 1 | 5 | 1 |
FN | 1 | 2 | 2 |
Frame index | N/A | 5 | -9 |
Double indexing can occur on source (read) or destination (write). Equations for rotation of xx degrees on destination are obtained by taking equations for rotation of (360 – xx) degrees on source, and swapping the width (x) and height (y) of the image in them. The opposite is also true. Table 16-11 lists the equations for 90-, 180-, and 270-degree rotations.
90° Rotation | 180° Rotation | 270° Rotation | ||
---|---|---|---|---|
Double indexing on destination (write) | Base address | ES*(y–1) | ES*(x*y–1) | ES*y*(x–1) |
EI | ES*(y–1) + 1 | 1–2*ES | 1–ES*(y + 1) | |
FI | 1 ES*[(x–1)*y + 2] | 1–2*ES | 1+ES*(x–1)*y | |
Double indexing on source (read) | Base address | ES*x*(y–1) | ES*(x*y–1) | ES*(x–1) |
EI | 1–ES*(x + 1) | 1–2*ES | ES*(x–1) + 1 | |
FI | 1+ES*(y–1)*x | 1–2*ES | 1 ES*[(y–1)*x + 2] |
Table 16-12 and Figure 16-10 show the configuration required to perform a 90-degree clockwise rotation of a 240 × 160 pixel, 32-bit image. The EI, frame size, and FI values are configured so that the image is rotated line-by-line starting at the left end of the top line.
The FI value for the destination is negative so that the first pixel of each subsequent line of the source image is written to the correct location at the destination.
Equation 5 and Equation 6 calculate the destination, FI and EI. The example assumes that the image lines are stored at consecutive addresses in memory, meaning that both EI and FI on the source side are 1.
Rotations:
Section 16.1.5.7, 90-Degree Clockwise Image Rotation, describes how to program an example of a 90-degree clockwise image rotation.
Observe that:
Parameter | Source Value | Destination Value |
---|---|---|
Bits per pixel | 32 | 32 |
ES | 4 | 4 |
Image width | SW | SH |
Image height | SH | SW |
Stride elements (stride EI) | 1 element | SH |
Stride frames (stride FI) | 1 element | –[(SW-1)*SH + 1] = 38,241 elements |
Start address | 0x100000 | 0x200000 + (SH 1) x ES = 0x20027C |
EN | SW | SW |
EI | [(Stride EI 1) * ES] + 1 = 1 | [(Stride EI 1) * ES] + 1 = 637 |
FN | SH | SH |
FI | [(Stride FI 1) * ES] + 1= 1 | [(Stride FI 1) * ES] + 1 = 152,967 |