Добавил:
ИВТ (советую зайти в "Несортированное") Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
interfeysy_1 / ИДЗ_машинка / даташиты / esp32_technical_reference_manual_en.pdf
Скачиваний:
16
Добавлен:
26.01.2024
Размер:
9.62 Mб
Скачать

6 DMA Controller (DMA)

Software can use a DMA Engine by assigning a linked list to define the DMA operational parameters.

The DMA Engine transmits the data from the RAM to a peripheral, according to the contents of the out_link descriptor. Also, the DMA Engine stores the data received from a peripheral into a specified RAM location, according to the contents of the in_link descriptor.

6.3.2Linked List

Figure 6­2. Linked List Structure

The DMA descriptor’s linked lists (out_link and in_link) have the same structure. As shown in Figure 6-2, a linked-list descriptor consists of three words. The meaning of each field is as follows:

owner (DW0) [31]: The allowed operator of the buffer corresponding to the current linked list. 1’b0: the allowed operator is the CPU;

1’b1: the allowed operator is the DMA controller.

eof (DW0) [30]: End-Of-File character.

1’b0: the linked-list item does not mark the end of the linked list; 1’b1: the linked-list item is at the end of the linked list.

reserved (DW0) [29:24]: Reserved bits. Software should not write 1’s in this space.

length (DW0) [23:12]: The number of valid bytes in the buffer corresponding to the current linked list. The field value indicates the number of bytes to be transferred to/from the buffer denoted by word DW1.

size (DW0) [11:0]: The size of the buffer corresponding to the current linked list.

NOTE: The size must be word-aligned.

buffer address pointer (DW1): Buffer address pointer. This is the address of the data buffer.

NOTE: The buffer address must be word-aligned.

next descriptor address (DW2): The address pointer of the next linked-list item. The value is 0, if the current linked-list item is the last on the list (eof=1).

When receiving data, if the data transfer length is smaller than the specified buffer size, DMA will not use the remaining space. This enables the DMA engine to be used for transferring an arbitrary number of data bytes.

6.4UART DMA (UDMA)

The ESP32 has three UART interfaces that share two UDMA (UART DMA) controllers. The UHCI_UARTx_CE (x is 0, 1, or 2) is used for selecting the UART controller to use the UDMA.

Espressif Systems

121

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

6 DMA Controller (DMA)

Figure 6­3. Data Transfer in UDMA Mode

Figure 6-3 shows the data transfer in UDMA mode. Before the DMA Engine receives data, software must initialize the receive-linked-list. UHCI_INLINK_ADDR is used to point to the first in_link descriptor. The register must be programmed with the lower 20 bits of the address of the initial linked-list item. After UHCI_INLINK_START is set, the Universal Host Controller Interface (UHCI) will transmit the data received by UART to the Decoder. After being parsed, the data will be stored in the RAM as specified by the receive-linked-list descriptor.

Before DMA transmits data, software must initialize the transmit-linked-list and the data to be transferred. UHCI_ OUTLINK_ADDR is used to point to the first out_link descriptor. The register must be programmed with the lower 20 bits of the address of the initial transmit-linked-list item. After UHCI_OUTLINK_START is set, the DMA Engine will read data from the RAM location specified by the linked-list descriptor and then transfer the data through the Encoder. The DMA Engine will then shift the data out serially through the UART transmitter.

The UART DMA follows a format of (separator + data + separator). The Encoder is used for adding separators before and after data, as well as using special-character sequences to replace data that are the same as separators. The Decoder is used for removing separators before and after data, as well as replacing the special-character sequences with separators. There can be multiple consecutive separators marking the beginning or end of data. These separators can be configured through UHCI_SEPER_CH, with the default values being 0xC0. Data that are the same as separators can be replaced with UHCI_ESC_SEQ0_CHAR0 (0xDB by default) and UHCI_ESC_SEQ0_CHAR1 (0xDD by default). After the transmission process is complete, a UHCI_OUT_TOTAL_EOF_INT interrupt will be generated. After the reception procedure is complete, a UHCI_IN_ SUC_EOF_INT interrupt will be generated.

Note:

Please note that the buffer address pointer field in in_link descriptors should be word-aligned, and the size field in the last in_link descriptor should be at least 4 bytes larger than the length of received data.

Espressif Systems

122

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

6 DMA Controller (DMA)

6.5SPI DMA Interface

Figure 6­4. SPI DMA

ESP32 SPI modules can use DMA as well as the CPU for data exchange with peripherals. As can be seen from Figure 6-4, two DMA channels are shared by SPI1, SPI2 and SPI3 controllers. Each DMA channel can be used by any one SPI controller at any given time.

The ESP32 SPI DMA Engine also uses a linked list to receive/transmit data. Burst transmission is supported. The data size for a single transfer must be four bytes aligned. Consecutive data transfer is also supported.

SPI1_DMA_CHAN_SEL[1:0], SPI2_DMA_CHAN_SEL[1:0] and SPI3_DMA_CHAN_SEL[1:0] in DPORT_SPI_DMA_ CHAN_SEL_REG must be configured to enable the SPI DMA interface for a specific SPI controller. Each SPI controller corresponds to one domain which has two bits with values 0, 1 and 2. Value 3 is reserved and must not be configured for operation.

Considering SPI1 as an example,

if SPI SPI1_DMA_CHAN_SEL[1:0] = 0, then SPI1 does not use any DMA channel; if SPI1_DMA_CHAN_SEL[1:0] = 1, then SPI1 enables DMA channel1;

if SPI1_DMA_CHAN_SEL[1:0] = 2, then SPI1 enables DMA channel2.

The SPI_OUTLINK_START bit in SPI_DMA_OUT_LINK_REG and the SPI_INLINK_START bit in SPI_DMA_IN_LINK_REG are used for enabling the DMA Engine. The two bits are self-cleared by hardware. When SPI_OUTLINK_START

is set to 1, the DMA Engine starts processing the outbound linked list descriptor and prepares to transmit data. When SPI_INLINK_START is set to 1, then the DMA Engine starts processing the inbound linked-list descriptor and gets prepared to receive data.

Software should configure the SPI DMA as follows:

1.Reset the DMA state machine and FIFO parameters;

2.Configure the DMA-related registers for operation;

3.Configure the SPI-controller-related registers accordingly;

4.Set SPI_USR to enable DMA operation.

Espressif Systems

123

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

6 DMA Controller (DMA)

6.6I2S DMA Interface

The ESP32 integrates two I2S modules, I2S0 and I2S1, each of which is powered by a DMA channel. The REG_I2S_DSCR_EN bit in I2S_FIFO_CONF_REG is used for enabling the DMA operation. ESP32 I2S DMA uses the standard linked-list descriptor to configure DMA operations for data transfer. Burst transfer is supported. However, unlike the SPI DMA channels, the data size for a single transfer is one word, or four bytes. REG_I2S_RX_EOF_NUM[31:0] bit in I2S_RXEOF_NUM_REG is used for configuring the data size of a single transfer operation, in multiples of one word.

I2S_OUTLINK_START bit in I2S_OUT_LINK_REG and I2S_INLINK_START bit in I2S_IN_LINK_REG are used for enabling the DMA Engine and are self-cleared by hardware. When I2S_OUTLINK_START is set to 1, the DMA Engine starts processing the outbound linked-list descriptor and gets prepared to send data. When I2S_INLINK_START is set to 1, the DMA Engine starts processing the inbound linked-list descriptor and gets prepared to receive data.

Software should configure the I2S DMA as follows:

1.Configure I2S-controller-related registers;

2.Reset the DMA state machine and FIFO parameters;

3.Configure DMA-related registers for operation;

4.In I2S master mode, set I2S_TX_START bit or I2S_RX_START bit to initiate an I2S operation;

In I2S slave mode, set I2S_TX_START bit or I2S_RX_START bit and wait for data transfer to be initiated by the host device.

For more information on I2S DMA interrupts, please see Section DMA Interrupts, in Chapter I2S.

Espressif Systems

124

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

Соседние файлы в папке даташиты