STM32F7 22 Advanced-control timers (TIM1/TIM8)

Started by tha, December 26, 2022, 03:05:39 PM

Previous topic - Next topic

tha

22.4.12 TIMx auto-reload register (TIMx_ARR)( x = 1, 8 )

Address offset: 0x2C
Reset value: 0xFFFF



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

tha

22.4.13 TIMx repetition counter register (TIMx_RCR)( x = 1, 8 )

Address offset: 0x30
Reset value: 0x0000



Bits 15:0 REP[15:0]: Repetition counter value
     บิตเหล่านี้ยอมให้ผู้ใช้ตั้งค่าอัตราการอัปเดตของ the compare registers (ตัวอย่างเช่น การส่งถ่ายเป็นระยะจาก preload ถึง active
     registers) เมื่อ preload registers ถูกเปิดกาใช้งาน, เช่นเดียวกันกับ the update interrupt generation rate, ถ้า interrupt นี้
     ถูกเปิดกาใช้งาน.
     แต่ละครั้งที่ the REP_CNT related downcounter ลงถึงศูนย์, an update event จะถูกสร้างและมันจะสตาร์ทใหม่การนับจาก REP
     value. ตามที่ REP_CNT ถูกโหลดใหม่ด้วย REP value ได้เฉพาะที่ the repetition update event U_RC, การเขียนใดๆไปยัง the
     TIMx_RCR register จะไม่ถูกคำนึงถึงจนกระทั่ง the next repetition update event.
     หมายความว่าใน PWM mode (REP+1) ตรงกันกับ :
     จำนวนของ PWM periods ใน edge-aligned mode
     จำนวนของ half PWM period ใน center-aligned mode

tha

22.4.14 TIMx capture/compare register 1 (TIMx_CCR1)( x = 1, 8 )

Address offset: 0x34
Reset value: 0x0000



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

22.4.18 TIMx break and dead-time register (TIMx_BDTR)( x = 1, 8 )

Address offset: 0x44
Reset value: 0x0000 0000



Note: ตามที่ the bits BK2P, BK2E, BK2F[3:0], BKF[3:0], AOE, BKP, BKE, OSSI, OSSR and DTG[7:0] สามารถถูกล็อคการ
          เขียนได้ขึ้นอยู่กับ the LOCK configuration, มันจำเป็นต้องกำหนดค่าทั้งหมดของพวกมันในระหว่าง the first write access ไป
          ยัง the TIMx_BDTR register.


Bits 31:26 Reserved, must be kept at reset value.

Bit 25 BK2P: Break 2 polarity
     0: Break input BRK2 is active low
     1: Break input BRK2 is active high
  Note: บิตนี้ไม่สามารถถูกแก้ไขได้ตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits in TIMx_BDTR register).
  Note: การดำเนินการเขียนไปยังบิตนี้จะใช้ a delay of 1 APB clock cycle เพื่อให้มีผล.


Bit 24 BK2E: Break 2 enable
     บิตนี้เปิดใช้งาน the complete break 2 protection (รวมถึงแหล่งที่มาทั้งหมดที่เชื่อมต่อกับ bk_acth and BKIN sources, ตาม
     Figure 191: Break and Break2 circuitry overview).
     0: Break2 function disabled
     1: Break2 function enabled
Note: The BRKIN2 ต้องถูกใช้เฉพาะกับ OSSR = OSSI = 1.
  Note: บิตนี้ไม่สามารถถูกแก้ไขได้ตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits in TIMx_BDTR register).
  Note: การดำเนินการเขียนไปยังบิตนี้จะใช้ a delay of 1 APB clock cycle เพื่อให้มีผล.


Bits 23:20 BK2F[3:0]: Break 2 filter
     bit-field นี้กำหนดความถี่ที่ใช้ในการสุ่ม BRK2 input และความยาวของ the digital filter ที่ใช้กับ BRK2. The digital filter ทำจาก
     an event counter ที่ N consecutive events จำเป็นต้องตรวจสอบความถูกต้อง a transition บน the output:
     0000: No filter, BRK2 ทำงานไม่ประสานพร้อมกัน
     0001: fSAMPLING=fCK_INT, N=2
     0010: fSAMPLING=fCK_INT, N=4
     0011: fSAMPLING=fCK_INT, N=8
     0100: fSAMPLING=fDTS/2, N=6
     0101: fSAMPLING=fDTS/2, N=8
     0110: fSAMPLING=fDTS/4, N=6
     0111: fSAMPLING=fDTS/4, N=8
     1000: fSAMPLING=fDTS/8, N=6
     1001: fSAMPLING=fDTS/8, N=8
     1010: fSAMPLING=fDTS/16, N=5
     1011: fSAMPLING=fDTS/16, N=6
     1100: fSAMPLING=fDTS/16, N=8
     1101: fSAMPLING=fDTS/32, N=5
     1110: fSAMPLING=fDTS/32, N=6
     1111: fSAMPLING=fDTS/32, N=8
  Note: บิตนี้ไม่สามารถถูกแก้ไขได้ตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits in TIMx_BDTR register).

Bits 19:16 BKF[3:0]: Break filter
     bit-field นี้กำหนดความถี่ที่ใช้ในการสุ่ม BRK input และความยาวของ the digital filter ที่ใช้กับ BRK. The digital filter ทำจาก
     an event counter ที่ N consecutive events จำเป็นต้องตรวจสอบความถูกต้อง a transition บน the output:
     0000: No filter, BRK ทำงานไม่ประสานพร้อมกัน
     0001: fSAMPLING=fCK_INT, N=2
     0010: fSAMPLING=fCK_INT, N=4
     0011: fSAMPLING=fCK_INT, N=8
     0100: fSAMPLING=fDTS/2, N=6
     0101: fSAMPLING=fDTS/2, N=8
     0110: fSAMPLING=fDTS/4, N=6
     0111: fSAMPLING=fDTS/4, N=8
     1000: fSAMPLING=fDTS/8, N=6
     1001: fSAMPLING=fDTS/8, N=8
     1010: fSAMPLING=fDTS/16, N=5
     1011: fSAMPLING=fDTS/16, N=6
     1100: fSAMPLING=fDTS/16, N=8
     1101: fSAMPLING=fDTS/32, N=5
     1110: fSAMPLING=fDTS/32, N=6
     1111: fSAMPLING=fDTS/32, N=8
  Note: บิตนี้ไม่สามารถถูกแก้ไขได้ตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits in TIMx_BDTR register).

tha

Bit 15 MOE: Main output enable
     บิตนี้ถูกเคลียร์แบบ asynchronous โดย hardware ทันทีที่หนึ่งใน the break input ทำงาน(BRK or BRK2). มันถูกเซ็ตโดย
     software หรือโดยอัตโนมัติขึ้นอยู่กับ the AOE bit. มันทำงานเพียงบน the channels ซึ่งถูกกำหนดค่าใน output.
     0: เพื่อตอบสนองต่อ a break 2 event. OC and OCN outputs จะถูกปิดการใช้งานเพื่อตอบสนองต่อ a break event หรือถ้า MOE
     ถูกเขียนเป็น 0: OC and OCN outputs จะถูกปิดการใช้งานหรือบังคับเป็น idle state ขึ้นอยู่กับ the OSSI bit.
     1: OC and OCN outputs จะถูกเปิดการใช้งานถ้า respective enable bits ของมันถูกเซ็ต (CCxE, CCxNE ใน TIMx_CCER
     register).
     ดู OC/OCN enable description สำหรับรายละเอียดที่มากขึ้น (Section 22.4.9: TIM1 and TIM8 capture/compare enable
     register (TIMx_CCER)( x = 1, 8 )).

Bit 14 AOE: Automatic output enable
     0: MOE สามารถถูกเซ็ตได้เพียงโดย software
     1: MOE สามารถถูกเซ็ตได้เพียงโดย software หรือโดยอัตโนมัติที่ the next update event (ถ้าไม่มี the break inputs BRK and
     BRK2 ทำงาน)
  Note: บิตนี้ไม่สามารถถูกแก้ไขตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits ใน TIMx_BDTR register).

Bit 13 BKP: Break polarity
     0: Break input BRK is active low
     1: Break input BRK is active high
Note: บิตนี้ไม่สามารถถูกแก้ไขตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits ใน TIMx_BDTR register).
  Note: write operation ใดๆไปยังบิตนี้จะหน่วงเวลา 1 APB clock cycle ถึงจะกลายเป็นผล.


Bit 12 BKE: Break enable
     บิตนี้เปิดใช้งาน the complete break protection (รวมถึงทุกแหล่งที่ต่อกับ bk_acth และ BKIN sources, ตาม Figure 191:
     Break and Break2 circuitry overview).
     0: Break function ถูกปิดการใช้งาน
     1; Break function ถูกเปิดการใช้งาน
  Note: บิตนี้ไม่สามารถถูกแก้ไขตราบเท่าที่ LOCK level 1 ถูกโปรแกรมแล้ว (LOCK bits ใน TIMx_BDTR register).
  Note: write operation ใดๆไปยังบิตนี้จะหน่วงเวลา 1 APB clock cycle ถึงจะกลายเป็นผล.

tha

Bit 11 OSSR: Off-state selection for Run mode
     บิตนี้ถูกใช้เมื่อ MOE=1 บน channels ที่มี a complementary output ซึ่งถูกกำหนดค่าเป็น outputs. OSSR ไม่ถูกจัดให้มีใช้ถ้าไม่มี
     complementary output ถูกจัดให้มีใช้ใน the timer.
     ดู OC/OCN enable description สำหรับรายละเอียดที่มากขึ้น (Section 22.4.9: TIM1 and TIM8 capture/compare enable
     register (TIMx_CCER)( x = 1, 8 )).
     0: เมื่อ inactive, OC/OCN outputs ถูกปิดการใช้งาน (the timer ปลดปล่อย the output control ซึ่งถูกควบคุมโดย the GPIO
     logic, ซึ่งบังคับ a Hi-Z state).
     1: เมื่อ inactive, OC/OCN outputs ถูกเปิดการใช้งานด้วย inactive level ของมันทันทีที่ CCxE=1 หรือ CCxNE=1 (the output
     ยังคงถูกควบคุมโดย the timer).
  Note: บิตนี้ไม่สามารถถูกแก้ไขตราบเท่าที่ LOCK level 2 ถูกโปรแกรมแล้ว (LOCK bits ใน TIMx_BDTR register).

Bit 10 OSSI: Off-state selection for Idle mode
     บิตนี้ถูกใช้เมื่อ MOE=0 เนื่องจาก a break event หรือโดย a software write, บน channels ที่กำหนดค่าเป็น outputs.
     ดู OC/OCN enable description สำหรับรายละเอียดที่มากขึ้น (Section 22.4.9: TIM1 and TIM8 capture/compare enable
     register (TIMx_CCER)( x = 1, 8 )).
     0: เมื่อ inactive, OC/OCN outputs ถูกปิดการใช้งาน (the timer ปลดปล่อย the output control ซึ่งถูกควบคุมโดย the GPIO
     logic, ซึ่งกำหนด a Hi-Z state).
     1: เมื่อ inactive, OC/OCN outputs ถูกบังคับเป็นอันดับแรกด้วย inactive level ของมันจากนั้นบังคับเป็น idle level หลังจาก the
     deadtime. The timer รักษาการควบคุมของมันครอบคุม the output.
  Note: บิตนี้ไม่สามารถถูกแก้ไขทันทีที่ LOCK level 2 ถูกโปรแกรมแล้ว (LOCK bits ใน TIMx_BDTR register).

tha

Bits 9:8 LOCK[1:0]: Lock configuration
     บิตเหล่านี้เสนอให้มี a write protection ต้าน software errors.
     00: LOCK OFF - ไม่มีบิตที่ถูกป้องกันการเขียน.
     01: LOCK Level 1 = DTG bits ใน TIMx_BDTR register, OISx และ OISxN bits ใน TIMx_CR2 register และ
           BKE/BKP/AOE bits ใน TIMx_BDTR register ไม่สามารถถูกเขียนได้อีกต่อไป.
     10: LOCK Level 2 = LOCK Level 1 + CC Polarity bits (CCxP/CCxNP bits ใน TIMx_CCER register, ตราบเท่าที่ the
           related channel ถูกกำหนดค่าใน output ผ่านทาง the CCxS bits) เช่นเดียวกันกับ OSSR and OSSI bits ไม่สามารถถูก
           เขียนได้อีกต่อไป.
     11: LOCK Level 3 = LOCK Level 2 + CC Control bits (OCxM และ OCxPE bits ใน TIMx_CCMRx registers, ตราบเท่า
           ที่ the related channel ถูกกำหนดค่าใน output ผ่านทาง the CCxS bits) ไม่สามารถถูกเขียนได้อีกต่อไป.
  Note: The LOCK bits สามารถถูกเขียนได้เพียงครั้งเดียวหลังจาก the reset. เมื่อ the TIMx_BDTR register ถูกเขียนแล้ว, สิ่งที่จุอยู่
            ภายในของมันจะถูกแช่แข็งจนกระทั่ง the next reset.


Bits 7:0 DTG[7:0]: Dead-time generator setup
     bit-field นี้กำหนด the duration ของ the dead-time ที่แทรกระหว่าง the complementary outputs. DT ตรงกันกับระยะเวลานี้.
     DTG[7:5]=0xx => DT=DTG[7:0]x tdtg with tdtg=tDTS.
     DTG[7:5]=10x => DT=(64+DTG[5:0])xtdtg with Tdtg=2xtDTS.
     DTG[7:5]=110 => DT=(32+DTG[4:0])xtdtg with Tdtg=8xtDTS.
     DTG[7:5]=111 => DT=(32+DTG[4:0])xtdtg with Tdtg=16xtDTS.
     ตัวอย่างถ้า TDTS=125ns (8MHz), dead-time possible values คือ:
     0 to 15875 ns by 125 ns steps,
     16 us to 31750 ns by 250 ns steps,
     32 us to 63us by 1 us steps,
     64 us to 126 us by 2 us steps
  Note: bit-field นี้ไม่สามารถถูกแก้ไขตราบเท่าที่ LOCK level 1, 2 or 3 ถูกโปรแกรมแล้ว (LOCK bits in TIMx_BDTR register).

tha

22.4.19 TIMx DMA control register (TIMx_DCR)( x = 1, 8 )

Address offset: 0x48
Reset value: 0x0000



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 or a write access ถูกทำ
     ไปยัง the TIMx_DMAR address), เช่น จำนวนของ transfers. Transfers สามารถเป็นใน half-words หรือใน bytes (ดูตัวอย่าง
     ข้างล่าง).
     00000: 1 transfer
     00001: 2 transfers
     00010: 3 transfers
     ...
     10001: 18 transfers
     Example: ให้เราพิจารณาการส่งถ่ายต่อไปนี้: DBL = 7 bytes และ DBA = TIM2_CR1.
     –   ถ้า DBL = 7 bytes และ DBA = TIM2_CR1 แสดง the address ของ the byte ที่จะถูกส่งถ่าย, the address ของ the
     transfer ควรถูกให้โดยสมการต่อไปนี้:
                              (TIMx_CR1 address) + DBA + (DMA index), โดยที่ DMA index = DBL
     ในตัวอย่างนี้, 7 bytes ถูกเพิ่มให้กับ (TIMx_CR1 address) + DBA, ซึ่งให้เร the address จาก/ถึง ซึ่ง the data จะถูกคัดลอก.
     ในกรณีนี้, the transfer จะถูกทำไปยัง 7 registers สตารทจาก the following address: (TIMx_CR1 address) + DBA
     สอดคล้องกับการกำหนดค่าของ the DMA Data Size, หลายกรณีอาจเกิดขึ้น:
     –   ถ้าคุณกำหนดค่า the DMA Data Size ใน half-words, 16-bit data จะถูกส่งถ่ายไปยังแต่ละของ the 7 registers.
     –   ถ้าคุณกำหนดค่า the DMA Data Size ใน bytes, the data จะถูกส่งถ่ายไปยัง 7 registers ด้วย: the first register จะบรรจุ
          the first MSB byte, the second register, the first LSB byte และต่อไป. ดังนั้นด้วย the transfer Timer, คุณจำเป็นต้อง
          ระบุขนาดของ data ที่ส่งถ่ายโดย DMA.

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

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