STM32F7 8 Direct memory access controller (DMA)

Started by tha, September 16, 2022, 09:00:56 AM

Previous topic - Next topic

tha

8 Direct memory access controller (DMA)

8.1 DMA introduction

Direct memory access (DMA) ถูกใช้เพื่อจัดให้มี high-speed data transfer ระหว่าง peripherals and memory และระหว่าง memory and memory. Data สามารถถูกย้ายอย่างรวดเร็วโดย DMA โดยไม่มี CPU action ใดๆ. สิ่งนี้ทำให้ CPU resources ฟรีสำหรับการทำงานอื่นๆ.

The DMA controller รวม a powerful dual AHB master bus architecture เข้ากับ independent FIFO เพื่อทำให้ the bandwidth of the system ดีขึ้น, บนฐานของ a complex bus matrix architecture

The two DMA controllers (DMA1 and DMA2) มีทั้งหมด 16 streams (8 สำหรับแต่ละ controller), แต่ละสตรีมอุทิศให้การจัดการ memory access requests จากหนึ่ง peripherals ขึ้นไป.

แต่ละ stream สามารถมีทั้งหมดมากถึง 8 channels (requests).

แต่ละ DMA controller มี an arbiter สำหรับจัดการ the priority ระหว่าง DMA requests

tha

8.2 DMA main features

The main DMA features คือ:
•   Dual AHB master bus architecture, ตัวหนึ่งอุทิศให้กับ memory accesses และอีกตัวหนึ่งอุทิศให้กับ peripheral accesses
•   AHB slave programming interface รองรับเฉพาะ 32-bit accesses
•   8 streams สำหรับแต่ละ DMA controller, มากถึง 8 channels (requests) ต่อ stream
•   Four-word depth 32 first-in, first-out memory buffers (FIFOs) ต่อ stream, ที่สามารถถูกใช้ใน FIFO mode หรือ direct
     mode:
     –   FIFO mode: ที่มี threshold level software selectable ระหว่าง 1/4, 1/2 or 3/4 ของ the FIFO size
     –   Direct mode: แต่ละ DMA request จะเริ่มต้น a transfer ทันทีจาก/ถึง the memory. เมื่อมันถูกกำหนดค่าใน direct mode
          (FIFO ถูกปิดใช้งาน), เพื่อส่งถ่าย data ใน memory-to-peripheral mode, the DMA จะโหลดก่อนเฉพาะ one data จาก
          the memory ไปยัง the internal FIFO เพื่อให้แน่ใจว่า an immediate data transfer ทันทีที่ a DMA request ถูกทริกโดย
          a peripheral.

tha

•   แต่ละ stream สามารถถูกกำหนดค่าเป็น:
     –   a regular channel ที่รองรับ peripheral-to-memory, memory-to-peripheral และ memory-to-memory transfers
     –   a double buffer channel ที่รองรับ double buffering บน the memory side ด้วย
•   Priorities ระหว่าง DMA stream requests เป็น software-programmable (4 ระดับประกอบด้วย very high, high, medium,
     low) หรือ hardware ในกรณีที่เท่ากัน (ตัวอย่างเช่น, request 0 มี priority สูงกว่า request 1)
•   แต่ละ stream รองรับ software trigger สำหรับ memory-to-memory transfers ด้วย (มีให้ใช้งานเฉพาะสำหรับ the DMA2
     controller)
•   แต่ละ stream request สามารถถูกเลือกในหมู่ที่มากถึง 8 possible channel requests. การเลือกนี้เป็น software-configurable
     และยอมให้หลาย peripherals เริ่มต้น DMA requests
•   จำนวนของ data items ที่จะถูกส่งถ่ายสามารถถูกจัดการโดย the DMA controller หรือโดย the peripheral อย่างใดอย่างหนึ่ง:
     –   DMA flow controller: จำนวนของ data items ที่จะถูกส่งถ่ายเป็น software-programmable จาก 1 ถึง 65535
     –   Peripheral flow controller: จำนวนของ data items ที่จะถูกส่งถ่ายจะไม่รู้จำนวนและถูกควบคุมโดย the source or the
          destination peripheral ที่จะส่งสัญญาน the end of the transfer โดย hardware


tha

•   Independent source and destination transfer width (byte, half-word, word): เมื่อ the data widths ของ the source
     and destination ไม่เท่ากัน, the DMA จะแพ็ค/เอาออกแพ็ค the necessary transfers โดยอัตโนมัติเพื่อทำให้ the bandwidth ดีขึ้น.
     คุณลักษณะนี้มีให้ใช้งานเฉพาะใน FIFO mode
•   Incrementing หรือ non-incrementing addressing สำหรับ source and destination
•   รองรับ incremental burst transfers ของ 4, 8 or 16 beats. ขนาดของ the burst เป็น software-configurable, โดยปกติเท่ากับ
     ครึ่งหนึ่งของ the FIFO size ของ the peripheral
•   แต่ละ stream รองรับ circular buffer management
•   5 event flags (DMA half transfer, DMA transfer complete, DMA transfer error, DMA FIFO error, direct mode error)
     ถูก OR เข้าด้วยกันใน a single interrupt request สำหรับแต่ละ stream

tha

8.3 DMA functional description

8.3.1 DMA block diagram

Figure 23 แสดง the block diagram of a DMA.


tha

8.3.2 DMA overview

The DMA controller ทำการ direct memory transfer: ในฐานะที่เป็น an AHB master, มันสามารถใช้ the control of the AHB bus matrix เพื่อเริ่มต้น AHB transactions.

มันดำเนินการ the following transactions:
•   peripheral-to-memory
•   memory-to-peripheral
•   memory-to-memory

The DMA controller จัดให้มี two AHB master ports: the AHB memory port, ที่มุ่งหมายให้ถูกเชื่อมต่อกับ memories และ the AHB peripheral port, ที่มุ่งหมายให้ถูกเชื่อมต่อกับ peripherals. อย่างไรก็ตาม, เพื่อยอมให้ memory-to-memory transfers, the AHB peripheral port จะต้องยังเข้าถึง the memories ด้วย.

The AHB slave port ถูกใช้เพื่อโปรแกรม the DMA controller (มันรองรับเฉพาะ 32-bit accesses).

Note: The DMA1 controller AHB peripheral port ไม่ถูกเชื่อมต่อถึง the bus matrix เหมือนในกรณีของ the DMA2 controller,
          ดังนั้นเฉพาะ DMA2 streams ที่สามารถดำเนินการ memory-to-memory transfers.


ดู Figure 1 สำหรับการใช้งานของระบบของ two DMA controllers.

tha

8.3.3 DMA transactions

A DMA transaction ประกอบด้วยลำดับของจำนวนที่ให้ไว้ของ data transfers. จำนวนของ data items ที่จะถูกส่งถ่ายและความกว้างของมัน (8-bit, 16-bit or 32-bit) สามารถตั้งโปรแกรมได้ทางซอฟต์แวร์.

แต่ละ DMA transfer ประกอบด้วยการดำเนินการสามอย่าง:
•   การโหลดจาก the peripheral data register หรือตำแน่งใน memory, ที่กำหนดที่อยู่ผ่านทาง the DMA_SxPAR or
     DMA_SxM0AR register
•   การจัดเก็บ the data ที่จะโหลดไปยัง the peripheral data register หรือตำแน่งใน memory, ที่กำหนดที่อยู่ผ่านทาง the
     DMA_SxPAR or DMA_SxM0AR register
•   การลดลงตอนหลังของ the DMA_SxNDTR register, ที่บรรจุจำนวนของ transactions ที่ยังต้องถูกดำเนินการ

หลังจากเหตุการณ์, the peripheral ส่ง a request signal ไปยัง the DMA controller. The DMA controller ให้บริการ the request ขึ้นอยู่กับ the channel priorities. ทันทีที่ the DMA controller เข้าถึง the peripheral, an Acknowledge signal ถูกส่งไปยัง the peripheral โดย the DMA controller. The peripheral จะปล่อย request ของมันทันทีที่มันได้รับ the Acknowledge signal จาก the DMA controller. เมื่อ the request ถูกถอนการยืนยันโดย the peripheral แล้ว, the DMA controller จะปล่อย the Acknowledge signal. หากมีการร้องขอเพิ่มเติม, the peripheral สามารถเริ่มต้น the next transaction.

tha

8.3.4 Channel selection

แต่ละ stream ถูกเชื่อมโยงกับ a DMA request ที่สามารถถูกเลือกได้จาก 816 possible channel requests. การเลือกถูกควบคุมโดย the CHSEL[23:0] bits ใน the DMA_SxCR register



The 8 requests จาก the peripherals (อย่างเช่น TIM, ADC, SPI, I2C) ถูกเชื่อมต่ออย่างเป็นอิสระกับแต่ละ channel และการเชื่อมต่อของพวกมันขึ้นอยู่กับการจัดให้มีใช้ของผลิตภัณฑ์.

Table 25 and Table 26 ให้ตัวอย่างของ DMA request mappings.