STM32F1 TIM2 to TIM5

Started by tha, September 30, 2020, 12:19:23 PM

Previous topic - Next topic

tha



Bits 15:0 ARR[15:0]: Prescaler value
ARR คือค่าที่ถูกโหลดใน the actual auto-reload register.
อ้าองอิงถึง the Section 15.3.1: Time-base unit สำหรับรายละเอียดที่มากขึ้นเกี่ยวกับ ARR update และ behavior.
The counter ถูก blocked ในขณะที่ the auto-reload value เป็นศูนย์.

tha



Bits 15:0 CCR1[15:0]: Capture/Compare 1 value
ถ้า channel CC1 ถูกกำหนดค่าเป็น output:
CCR1 คือค่าที่ถูกโหลดใน the actual capture/compare 1 register (preload value). มันถูกโหลดอย่างถาวรถ้า the preload feature ไม่ได้ถูกเลือกใน the TIMx_CCMR1 register (bit OC1PE). ถ้าเป็นอย่างอื่น the preload value ถูกคัดลอกลงใน the active capture/compare 1 register เมื่อ an update event เกิดขึ้น.
The active capture/compare register บรรจุค่าที่ถูกเปรียบเทียบกับ the counter TIMx_CNT และให้สัญญาณบน OC1 output.

ถ้า channel CC1 ถูกกำหนดค่าเป็น input:
CCR1 คือ the counter value ที่ส่งถ่ายโดย the last input capture 1 event (IC1). The TIMx_CCR1 register อ่านได้เพียงอย่างเดียวและไม่สามารถถูกโปรแกรม.


tha



tha



Bits 15:13 Reserved, must be kept at reset value.

Bits 12:8 DBL[4:0]: DMA burst length
5-bit vector นี้กำหนดจำนวนของ DMA transfers (the timer จะจดจำ a burst transfer เมื่อ a read หรือ a write access ถูกทำกับ the TIMx_DMAR address).
     00000: 1 transfer,
     00001: 2 transfers,
     00010: 3 transfers,
     ...
     10001: 18 transfers.

Bits 7:5 Reserved, must be kept at reset value.

Bits 4:0 DBA[4:0]: DMA base address
5-bit vector นี้กำหนด the base-address สำหรับ DMA transfers (เมื่อ read/write access ถูกทำผ่านทาง the TIMx_DMAR address). DBA ถูกกำหนดเป็น an offset(ค่าที่เพิ่มขึ้น) เริ่มจาก the address ของ the TIMx_CR1 register.
     Example:
     00000: TIMx_CR1,
     00001: TIMx_CR2,
     00010: TIMx_SMCR,
     ...

Example: ให้เราพิจารณาการส่งถ่ายต่อไปนี้: DBL = 7 transfers & DBA = TIMx_CR1. ในกรณีนี้ the transfer ถูกทำจาก
               ไปยัง/จาก 7 registers เริ่มจาก the TIMx_CR1 address.

tha



Bits 15:0 DMAB[15:0]: DMA register for burst accesses
A read หรือ write operation ถึง the DMAR register เข้าถึง the register ในตำแหน่งที่ the address
            (TIMx_CR1 address) + (DBA + DMA index) x 4
ที่ TIMx_CR1 address คือ the address ของ the control register 1, DBA คือ the DMA base address ถูกกำหนดค่าใน TIMx_DCR register, DMA index ถูกควบคุมโดยอัตโนมัติโดย the DMA transfer, และมีย่านจาก 0 ถึง DBL (DBL ถูกกำหนดค่าใน TIMx_DCR).

tha

ตัวอย่างของวิธีการใช้ the DMA burst feature
ในตัวอย่างนี้ the timer DMA burst feature ถูกใช้เพื่ออัปเดตสิ่งที่อยู่ภายในของ the CCRx registers (x = 2, 3, 4) ด้วย the DMA transferring half words ลงใน the CCRx registers นี้ถูกทำในขั้นตอนต่อไปนี้:
1. กำหนดค่า the corresponding DMA channel ดังต่อไปนี้:
   – DMA channel peripheral address คือ the DMAR register address
   – DMA channel memory address คือ the address ของ the buffer ใน the RAM บรรจุ the data ที่จะถูกส่งถ่ายโดย DMA
      ลงใน CCRx registers.
   – จำนวนของ data ที่จะ transfer = 3 (ดู note ข้างล่าง).
   – Circular mode ถูกปิดการใช้งาน.
2. กำหนดค่า the DCR register โดยการกำหนดค่า the DBA และ DBL bit fields ดังต่อไปนี้: DBL = 3 transfers, DBA = 0xE.
3. เปิดการใช้งาน the TIMx update DMA request (เซ็ต the UDE bit ใน the DIER register).
4. เปิดการใช้งาน TIMx
5. เปิดการใช้งาน the DMA channel

Note: ตัวอย่างนี้สำหรับกรณีที่ทุก CCRx register ถูกอัปเดตหนึ่งครั้ง. ถ้าทุก CCRx register ต้องถูกอัปเดตสองครั้ง ตัวอย่างเช่น,
         จำนวนของ data ที่จะ transfer ควรเป็น 6. ลองยกตัวอย่างของ a buffer ใน the RAM บรรจุ data1, data2, data3, data4,
         data5 และ data6. The data ถูกส่งถ่ายถึง the CCRx registers ดังต่อไปนี้: บน the first update DMA request, data1
         ถูกส่งถ่ายถึง CCR2, data2 ถูกส่งถ่ายถึง CCR3, data3 ถูกส่งถ่ายถึง CCR4 และบน the second update DMA request,
         data4 ถูกส่งถ่ายถึง CCR2, data5 ถูกส่งถ่ายถึง CCR3 และ data6 ถูกส่งถ่ายถึง CCR4.

tha




ปล. ก็จบไปอีกตอน อากาศมันเย็นนะวันนี้ ก็เลยได้มากหน่อย ท่านใดไม่เข้าใจก็สอบถามทางอีทีทีกับอีเล็คทูเดย์เอานะ ทำกันเป็นทีมใช่ไหม