STM32F7 8 Direct memory access controller (DMA)

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

Previous topic - Next topic

tha

8.3.5 Arbiter

An arbiter จัดการ the 8 DMA stream requests ตาม priority ของพวกมันสำหรับแต่ละของ the two AHB master ports (memory and peripheral ports) และเริ่ม the peripheral/memory access sequences.

Priorities ถูกจัดการใน two stages:
•   Software: แต่ละ stream priority สามารถถูกกำหนดค่าใน the DMA_SxCR register. มี four levels:
     –   Very high priority
     –   High priority
     –   Medium priority
     –   Low priority
•   Hardware: ถ้า two requests มี the same software priority level, the stream ที่มี the lower number จะได้ priority
     เหนือ the stream ที่มี the higher number. ตัวอย่างเช่น, stream 2 จะได้ priority เหนือ stream 4.

tha

8.3.6 DMA streams

แต่ละของ the 8 DMA controller streams จัดให้มี a unidirectional transfer เชื่อมโยงระหว่างต้นทางและปลายทาง.

แต่ละ stream สามารถถูกกำหนดค่าเพื่อดำเนินการ:
•   Regular type transactions: memory-to-peripherals, peripherals-to-memory or memoryto-memory transfers
•   Double-buffer type transactions: double buffer transfers โดยใช้ two memory pointers สำหรับ the memory (ในขณะ
     ที่ the DMA กำลังอ่าน/เขียน จาก/ถึง a buffer, the application สามารถ เขียน/อ่าน ถึง/จาก the other buffer).

จำนวนของ data ที่จะถูกส่งถ่าย (มากถึง 65535) สามารถโปรแกรมได้และสัมพันธ์กับความกว้างต้นทางของ the peripheral ที่ร้องขอ the DMA transfer ที่ต่อกับ the peripheral AHB port. The register ที่บรรจุจำนวนของ data items ที่จะถูกส่งถ่ายถูกลดลงหลังจากแต่ละ transaction.

tha

8.3.7 Source, destination and transfer modes

ทั้ง source and destination transfers สามารถกำหนดที่อยู่ peripherals and memories ใน the entire 4 Gbytes area, ตามที่อยู่ประกอบด้วยระหว่าง 0x0000 0000 and 0xFFFF FFFF.

The direction ถูกกำหนดค่าโดยใช้ the DIR[1:0] bits in the DMA_SxCR register และเสนอสามทิศทางที่สามารถเป็นไปได้: memory-to-peripheral, peripheral-to-memory or memory-to-memory transfers. Table 27 อธิบาย the corresponding source and destination addresses.



เมือ่ the data width (ที่โปรแกรมใน the PSIZE or MSIZE bits ใน the DMA_SxCR register) เป็น a half-word หรือ a word, ตามลำดับ, the peripheral or memory address ที่เขียนลงใน the DMA_SxPAR or DMA_SxM0AR/M1AR registers ต้องถูกวางแนวบน a word หรือ half-word address boundary, ตามลำดับ.


tha

Peripheral-to-memory mode

Figure 25 อธิบายโหมดนี้.

เมื่อโหมดนี้ถูกเปิดใช้งาน (โดยการเซ็ต the bit EN ใน the DMA_SxCR register), แต่ละครั้งที่ a peripheral request เกิดขึ้น, the stream จะเริ่มต้น a transfer จาก the source เพื่อเติม the FIFO.

เมื่อ the threshold level ของ the FIFO ถูกถึง, สิ่งที่จุอยู่ภายในของ the FIFO จะถูกระบายออกและถูกเก็บลงใน the destination.

The transfer จะหยุดทันทีที่ the DMA_SxNDTR register ถึงศูนย์, เมื่อ the peripheral ร้องขอ the end of transfers (ในกรณีของ a peripheral flow controller) หรือเมื่อ the EN bit ใน the DMA_SxCR register ถูกเคลียร์โดย software.

ใน direct mode (เมื่อ the DMDIS value ใน the DMA_SxFCR register เป็น '0'), the threshold level ของ the FIFO จะไม่ถูกใช้: หลังจากแต่ละ single data transfer จาก the peripheral ไปยัง the FIFO, the corresponding data จะถูกระบายออกทันทีและถูกเก็บลงใน the destination.

The stream เข้าถึงไปยัง the AHB source หรือ destination port เฉพาะถ้า the arbitration ของ the corresponding stream ได้รับชัยชนะ. arbitration นี้ถูกดำเนินการโดยใช้ the priority ที่กำหนดสำหรับแต่ละ stream โดยใช้ the PL[1:0] bits ใน the DMA_SxCR register.


tha

Memory-to-peripheral mode

Figure 26 อธิบายโหมดนี้.

เมื่อโหมดนี้ถูกเปิดใช้งาน (โดยการเซ็ต the bit EN ใน the DMA_SxCR register), the stream จะเริ่มต้น transfers ทันทีจาก the source เพื่อเติม the FIFO ทั้งหมด.

แต่ละครั้งที่ a peripheral request เกิดขึ้น, สิ่งที่จุอยู่ภายในของ the FIFO จะถูกระบายออกและถูกเก็บลงใน the destination. เมื่อระดับของ the FIFO ต่ำกว่าหรือเท่ากับ the predefined threshold level, the FIFO จะถูกโหลดใหม่จนเต็มด้วย data จาก the memory.

The transfer จะหยุดทันทีที่ the DMA_SxNDTR register ถึงศูนย์, เมื่อ the peripheral ร้องขอ the end of transfers (ในกรณีของ a peripheral flow controller) หรือเมื่อ the EN bit ใน the DMA_SxCR register ถูกเคลียร์โดย software.

ใน direct mode (เมื่อ the DMDIS value ใน the DMA_SxFCR register เป็น '0'), the threshold level ของ the FIFO จะไม่ถูกใช้. ทันทีที่ the stream ถูกเปิดใช้งาน, the DMA จะโหลดก่อน the first data ที่จะ transfer ลงใน an internal FIFO. ทันทีที่ the peripheral ร้องขอ a data transfer, the DMA จะส่งถ่าย the preloaded value ลงใน the configured destination. จากนั้นจะโหลดใหม่อีกครั้ง the empty internal FIFO ด้วย the next data ที่จะถูก transfer. The preloaded data size ตรงกันกับ the value ของ the PSIZE bitfield ใน the DMA_SxCR register.

The stream เข้าถึงไปยัง the AHB source หรือ destination port เฉพาะถ้า the arbitration ของ the corresponding stream ได้รับชัยชนะ. arbitration นี้ถูกดำเนินการโดยใช้ the priority ที่กำหนดสำหรับแต่ละ stream โดยใช้ the PL[1:0] bits ใน the DMA_SxCR register.


tha

Memory-to-memory mode

The DMA channels สามารถทำงานโดยไม่มีการถูกทริกโดย a request จาก a peripheral ได้อีกด้วย. นี้คือ the memory-to-memory mode, ที่อธิบายใน Figure 27.

เมื่อ the stream ถูกเปิดใช้งานโดยการเซ็ต the Enable bit (EN) ใน the DMA_SxCR register, the stream จะสตาร์ททันทีเพื่อเติม the FIFO จนถึง the threshold level. เมื่อ the threshold level ถูกถึง, the FIFO contents จะถูกระบายออกและถูกเก็บลงใน the destination.

The transfer จะหยุดทันทีที่ the DMA_SxNDTR register ถึงศูนย์หรือเมื่อ the EN bit ใน the DMA_SxCR register ถูกเคลียร์โดย software.

The stream เข้าถึงไปยัง the AHB source หรือ destination port เฉพาะถ้า the arbitration ของ the corresponding stream ได้รับชัยชนะ. arbitration นี้ถูกดำเนินการโดยใช้ the priority ที่กำหนดสำหรับแต่ละ stream โดยใช้ the PL[1:0] bits ใน the DMA_SxCR register.

Note: เมื่อ memory-to-memory mode ถูกใช้, the circular and direct modes ไม่ถูกอนุญาต. เฉพาะ the DMA2 controller ที่
          สามารถดำเนินการ memory-to-memory transfers ได้
.



tha

8.3.8 Pointer incrementation

Peripheral and memory pointers สามารถเลือกถูกเพิ่มขึ้นภายหลังโดยอัตโนมัติหรือเก็บคงที่ไว้หลังจากแต่ละ transfer ขึ้นอยู่กับ the PINC and MINC bits ใน the DMA_SxCR register.

การปิดใช้งาน the increment mode จะมีประโยชน์เมื่อ the peripheral source หรือ destination data ถุกเข้าถึงผ่านทาง a single register.

ถ้า the increment mode ถูกเปิดใช้งาน, the address of the next transfer คือ the address ของตัวก่อนหน้าที่เพิ่มขึ้น 1 (สำหรับ bytes), 2 (สำหรับ half-words) หรือ 4 (สำหรับ words) ขึ้นอยู่กับ the data width ที่โปรแกรมใน the PSIZE or MSIZE bits ใน the DMA_SxCR register.

เพื่อปรับ the packing operation ให้ดีขึ้น, สามารถทำได้ที่จะคงที่ the increment offset size สำหรับ the peripheral address ไม่ว่าขนาดของ the data ที่ส่งถ่ายบน the AHB peripheral port มีขนาดเท่าใดก็ตาม. The PINCOS bit ใน the DMA_SxCR register ถูกใช้เพื่อวางแนว the increment offset size ด้วย the data size บน the peripheral AHB port, หรือบน a 32-bit address (the address ดังนั้นถูกเพิ่มขึ้น 4). The PINCOS bit มีผลกับ the AHB peripheral port เท่านั้น.

ถ้า the PINCOS bit ถูกเซ็ต, the address ของการส่งถ่ายที่ตามมาคือ the address ของตัวก่อนหน้าที่เพิ่มขึ้น 4 (ถูกวางแนวบน a 32-bit address โดยอัตโนมัติ), ไม่ว่า the PSIZE value มีขนาดเท่าใดก็ตาม. The AHB memory port, อย่างไรก็ตาม, ไม่ได้รับผลกระทบจากการดำเนินการนี้.

tha

8.3.9 Circular mode

The circular mode มีให้ใช้งานเพื่อจัดการ circular buffers และการไหลของดาต้าอย่างต่อเนื่อง (ตัวอย่างเช่น ADC scan mode). คุณลักษณะนี้สามารถถูกเปิดใช้งานโดยใช้ the CIRC bit ใน the DMA_SxCR register.

เมื่อ the circular mode ถูกทำให้ทำงาน, จำนวนของ data items ที่จะถูกส่งถ่ายจะถูกโหลดใหม่โดยอัตโนมัติด้วย the initial value ที่โปรแกรมในระหว่าง the stream configuration phase, และ the DMA requests ต่อเนื่องที่จะให้บริการ.

Note: ใน the circular mode, จำเป็นต้องปฏิบัติตามกฎต่อไปนี้ ในกรณีของ a burst mode ที่กำหนดค่าสำหรับ memory:
                               DMA_SxNDTR = ผลคูรของ ((Mburst beat) × (Msize)/(Psize)), โดยที่:
                           –   (Mburst beat) = 4, 8 or 16 (ขึ้นอยู่กับ the MBURST bits ใน the DMA_SxCR register)
                           –   ((Msize)/(Psize)) = 1, 2, 4, 1/2 or 1/4 (Msize and Psize แทน the MSIZE and PSIZE bits ใน
                                the DMA_SxCR register. พวกมันเป็น byte dependent)
                           –   DMA_SxNDTR = จำนวนของ data items ที่จะส่งถ่ายบน the AHB peripheral port

          ตัวอย่างเช่น: Mburst beat = 8 (INCR8), MSIZE = '00' (byte) and PSIZE = '01' (half-word), ในกรณีนี้:
          DMA_SxNDTR ต้องเป็นผลคุณของ (8 × 1/2 = 4).

          ถ้าสูตรนี้ไม่ถูกปฏิบัติตาม, the DMA behavior และ data integrity จะไม่ถูกรับประกัน.

          NDTR ต้องเป็นผลคุณของ the Peripheral burst size ที่คูณโดย the peripheral data size, มิฉะนั้น อาจส่งผลให้เกิด a bad
          DMA behavior