STM32F1 DMA

Started by tha, September 24, 2020, 07:28:27 AM

Previous topic - Next topic

tha

13.3.6 Interrupts
An interrupt สามารถถูกผลิตเมื่อ a Half-transfer, Transfer complete หรือ Transfer error สำหรับแต่ละ DMA channel. มี interrupt enable bits ให้ใช้งานแยกกันต่างหากสำหรับความ flexibility.



Note: ใน high-density และ XL-density devices, DMA2 Channel4 และ DMA2 Channel5 interrupts ถูก mapped ลงบน the same interrupt vector. ใน connectivity line devices, DMA2 Channel4 และ DMA2 Channel5 interrupts มี interrupt vectors แยกกันต่างหาก. ส่วน DMA1 และ DMA2 Channel interrupts อื่นทั้งหมด จะมี interrupt vector เป็นของมันเอง.

tha

13.3.7 DMA request mapping
DMA1 controller
The 7 requests(การร้องขอ) จาก the peripherals (TIMx[1,2,3,4], ADC1, SPI1, SPI/I2S2, I2Cx[1,2] และ USARTx[1,2,3]) ถูกออร์(OR)เข้าด้วยกันง่ายๆก่อนเข้าสู่ the DMA1, นี้หมายความว่ามีการร้องขอหนึ่งเดียวเท่านั้นที่ต้องถูกเปิดใช้งานในเวลาหนึ่งๆ.อ้างอิงถึงรูปที่ 50.

The peripheral DMA requests สามารถถูกทำให้ทำงาน/ทำให้ไม่ทำงาน โดยการโปรแกรม the DMA control bit ใน the registers เหล่านั้นของ the corresponding peripheral.





ปล. ก็ลองไล่ดูเอาว่าชาแนลไหนรับการร้องขอจาก peripheral ไหนได้บ้าง เช้านี้พอแค่นี้ก่อนครับ

tha

DMA2 controller
The five requests จาก the peripherals (TIMx[5,6,7,8], ADC3, SPI/I2S3, UART4, DAC_Channel[1,2] and SDIO) ถูกออร์(OR)เข้าด้วยกันง่ายๆก่อนเข้าสู่ the DMA2, นี้หมายความว่ามีการร้องขอหนึ่งเดียวเท่านั้นที่ต้องถูกเปิดใช้งานในเวลาหนึ่งๆ.อ้างอิงถึงรูปที่ 51.

The peripheral DMA requests สามารถถูกทำให้ทำงาน/ทำให้ไม่ทำงาน โดยการโปรแกรม the DMA control bit ใน the registers เหล่านั้นของ the corresponding peripheral.


Note: The DMA2 controller และการร้องขอที่สัมพันธ์กันของมันมีให้ใช้งานใน high-density, XL-density และ connectivity line devices เท่านั้น.



tha

13.4 DMA registers
อ้างถึง Section 2.2 บนหน้า 45 สำหรับรายการย่อที่ใช้ใน register descriptions.

Note: ใน registers ต่อไปนี้, บิตทั้งหมดที่เกี่ยวข้องกับ channel6 และ channel7 ไม่เกี่ยวข้องกับ DMA2 เนื่องจากมันมีเพียง 5 channels.

The peripheral registers สามารถถูกเข้าถึงโดย bytes (8-bit), half-words (16-bit) or words (32-bit).



      Bits 31:28 สงวนไว้, ต้องถูกเก็บไว้ที่ reset value.
      Bits 27, 23, 19, 15,  TEIFx: Channel x transfer error flag (x = 1 ..7)
                     11, 7, 3   บิตนี้ถูกเซ็ตโดย hardware. เคลียร์โดย software โดยการเขียน 1 ไปยังบิตที่ตรงกันใน the
                                    DMA_IFCR register.
                                    0: ไม่มี transfer error (TE) บน channel x
                                    1 : A transfer error (TE) เกิดขึ้นบน channel x
     Bits 26, 22, 18, 14, HTIFx: Channel x half transfer flag (x = 1 ..7)
                     10, 6, 2  บิตนี้ถูกเซ็ตโดย hardware. เคลียร์โดย software โดยการเขียน 1 ไปยังบิตที่ตรงกันใน the
                                   DMA_IFCR register.
                                   0: ไม่มี half transfer (HT) event บน channel x
                                   1: A half transfer (HT) event เกิดขึ้นบน channel x
     Bits 25, 21, 17, 13, TCIFx: Channel x transfer complete flag (x = 1 ..7)
                      9, 5, 1   บิตนี้ถูกเซ็ตโดย hardware. เคลียร์โดย software โดยการเขียน 1 ไปยังบิตที่ตรงกันใน the
                                   DMA_IFCR register.
                                   0: ไม่มี transfer complete (TC) event บน channel x
                                   1: A transfer complete (TC) event เกิดขึ้นบน channel x
     Bits 24, 20, 16, 12, GIFx: Channel x global interrupt flag (x = 1 ..7)
                      8, 4, 0   บิตนี้ถูกเซ็ตโดย hardware. เคลียร์โดย software โดยการเขียน 1 ไปยังบิตที่ตรงกันใน the
                                   DMA_IFCR register.
                                   0: ไม่มี TE, HT or TC event บน channel x
                                   1: A TE, HT or TC event เกิดขึ้นบน channel x

tha



     Bits 31:28 สงวนไว้, ต้องถูกเก็บไว้ที่ reset value.
     Bits 27, 23, 19, 15, CTEIFx: Channel x transfer error clear (x = 1 ..7)
                    11, 7, 3   บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                                  0: ไม่มีผลอะไร
                                  1: เคลียร์ the corresponding TEIF flag ใน the DMA_ISR register
     Bits 26, 22, 18, 14, CHTIFx: Channel x half transfer clear (x = 1 ..7)
                    10, 6, 2   บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                                  0: ไม่มีผลอะไร
                                  1: เคลียร์ the corresponding HTIF flag ใน the DMA_ISR register
     Bits 25, 21, 17, 13, CTCIFx: Channel x transfer complete clear (x = 1 ..7)
                      9, 5, 1   บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                                   0: ไม่มีผลอะไร
                                   1: เคลียร์ the corresponding TCIF flag ใน the DMA_ISR register
     Bits 24, 20, 16, 12, CGIFx: Channel x global interrupt clear (x = 1 ..7)
                      8, 4, 0   บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                                   0: ไม่มีผลอะไร
                                   1: เคลียร์ the GIF, TEIF, HTIF and TCIF flags ใน the DMA_ISR register

ปล. อันนี้ต้องมีการเคลียร์แฟลค เมื่อแฟลคมันเซ็ตแล้ว แต่อยู่คนละรีจีสเตอร์กัน ไม่ยากใช่มั๊ย

tha



     Bits 31:15 สงวนไว้, ต้องถูกเก็บไว้ที่ reset value.
     Bit 14 MEM2MEM: Memory to memory mode
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              0: ปิดการใช้งาน Memory to memory mode
              1: เปิดการใช้งาน Memory to memory mode
     Bits 13:12 PL[1:0]: Channel priority level
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              00: Low
              01: Medium
              10: High
              11: Very high
     Bits 11:10 MSIZE[1:0]: Memory size
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              00: 8-bits
              01: 16-bits
              10: 32-bits
              11: สงวนไว้
     Bits 9:8 PSIZE[1:0]: Peripheral size
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              00: 8-bits
              01: 16-bits
              10: 32-bits
              11: Reserved
     Bit 7 MINC: Memory increment mode
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              0: ปิดการใช้งาน Memory increment mode
              1: เปิดการใช้งาน Memory increment mode
     Bit 6 PINC: Peripheral increment mode
               บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              0: ปิดการใช้งาน Peripheral increment mode
              1: เปิดการใช้งาน Peripheral increment mode
     Bit 5 CIRC: Circular mode
              บิตนี้ถูกเซ็ตและเคลียร์โดย software.
              0: ปิดการใช้งาน Circular mode
              1: เปิดการใช้งาน Circular mode
     Bit 4 DIR: Data transfer direction
               บิตนี้ถูกเซ็ตและเคลียร์โดย software.
               0: อ่านจาก peripheral
               1: อ่านจาก memory
     Bit 3 TEIE: Transfer error interrupt enable
                บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                0: ปิดการใช้งาน TE interrupt
                1: เปิดการใช้งาน TE interrupt
     Bit 2 HTIE: Half transfer interrupt enable
                บิตนี้ถูกเซ็ตและเคลียร์โดย software.
                0: ปิดการใช้งาน HT interrupt
                1: เปิดการใช้งาน HT interrupt
     Bit 1 TCIE: Transfer complete interrupt enable
               บิตนี้ถูกเซ็ตและเคลียร์โดย software.
               0: ปิดการใช้งาน TC interrupt
               1: เปิดการใช้งาน TC interrupt
     Bit 0 EN: Channel enable
               บิตนี้ถูกเซ็ตและเคลียร์โดย software.
               0: ปิดการใช้งาน Channel
               1: เปิดการใช้งาน Channel

tha



     Bits 31:16 สงวนไว้, ต้องถูกเก็บไว้ที่ reset value.
     Bits 15:0 NDT[15:0]: Number of data to transfer
                   จำนวนของ data ที่ถูก transferred (0 ไปถึง 65535). register นี้สามารถถูกเขียนเมื่อ the channel นี้ถูกปิดการใช้
                   งาน. เมื่อ the channel นี้เปิดการใช้งานแล้ว, register นี้อ่านได้เพียงอย่างเดียว, แสดงจำนวน bytes ที่ยังเหลืออยู่ที่จะถูก
                   transmitted. register ลดลงหลังจากแต่ละ DMA transfer. เมื่อ the transfer นี้เสร็จสมบูรณ์, register นี้สามารถที่จะ
                   อยู่ที่ศูนย์หรือจะโหลดซ้ำใหม่โดยอัตโนมัติโดยค่าก่อนหน้าที่โปรแกรมเอาไว้ ถ้า the channel นี้ถูกกำหนดค่าใน autoreload
                   mode.
                   ถ้า register นี้เป็นศูนย์, ไม่มี transaction ใดสามารถให้บริการได้ไม่ว่า the channel ถูกเปิดการใช้งานหรือไม่ก็ตาม.

tha



      Bits 31:0 PA[31:0]: Peripheral address
                        แอดเดรสฐานของ the peripheral data register จาก/ถึง ซึ่ง the data จะถูกอ่าน/เขียน.
                        เมื่อ PSIZE เป็น 01 (16-bit), the PA[0] bit จะถูกละเลย. การเข้าถึงถูกวางแนวอย่างอัตโนมัติเป็น a halfword
                        address.
                        เมื่อ PSIZE เป็น 10 (32-bit), PA[1:0] จะถูกละเลย. การเข้าถึงถูกวางแนวอย่างอัตโนมัติเป็น a word address.