STM32F7 22 Advanced-control timers (TIM1/TIM8)

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

Previous topic - Next topic

tha

22.3.13 Combined PWM mode

Combined PWM mode ยอมให้ two edge or center-aligned PWM signals ถูกสร้างด้วย programmable delay และ phase shift ระหว่างพัลส์ตามลำดับ. ในขณะที่ the frequency ถูกกำหนดโดยค่าของ the TIMx_ARR register, the duty cycle และ delay ถูกกำหนดโดย the two TIMx_CCRx registers. The resulting signals, OCxREFC, ถูกทำจาก an OR or AND logical combination ของ two reference PWMs:
     –   OC1REFC (or OC2REFC) ถูกควบคุมโดย TIMx_CCR1 and TIMx_CCR2
     –   OC3REFC (or OC4REFC) ถูกควบคุมโดย TIMx_CCR3 and TIMx_CCR4

Combined PWM mode สามารถถูกเลือกอย่างอิสระบน two channels (หนึ่ง OCx output ต่อคู่ของ CCR registers) โดยการเขียน '1100' (Combined PWM mode 1) หรือ '1101' (Combined PWM mode 2) ใน the OCxM bits ใน the TIMx_CCMRx register

เมื่อ a given channel ถูกใช้เป็น combined PWM channel, complementary channel ของมันต้องถูกกำหนดค่าใน the opposite PWM mode (ตัวอย่างเช่น, ชาแนลหนึ่งใน Combined PWM mode 1 และชาแนลอื่นใน Combined PWM mode 2).

Note: The OCxM[3:0] bit field ถูกแบ่งออกเป็นสองส่วนตามเหตุผลด้านความเข้ากันได้, the most significant bit ไม่อยู่ติดกันกับ
          the 3 least significant ones.


Figure 186 แสดงตัวอย่างสัญญาณที่สามารถถูกสร้างโดยใช้ Asymmetric PWM mode, ได้รับจากการกำหนดค่าต่อไปนี้:
     –   Channel 1 ถูกกำหนดค่าใน Combined PWM mode 2,
     –   Channel 2 ถูกกำหนดค่าใน PWM mode 1,
     –   Channel 3 ถูกกำหนดค่าใน Combined PWM mode 2,
     –   Channel 4 ถูกกำหนดค่าใน PWM mode 1.


tha

22.3.14 Combined 3-phase PWM mode

Combined 3-phase PWM mode ยอมให้หนึ่งถึงสาม center-aligned PWM signals ถูกสร้างด้วย a single programmable signal ที่ AND ในตรงกลางของพัลส์. The OC5REF signal ถูกใช้เพื่อกำหนด the resulting combined signal. The 3-bits GC5C[3:1] ใน the TIMx_CCR5 ยอมให้การเลือกซึ่ง reference signal the OC5REF ถูกรวม. The resulting signals, OCxREFC, ถูกทำจาก an AND logical combination ของ two reference PWMs
     –   ถ้า GC5C1 ถูกเซ็ต, OC1REFC จะถูกควบคุมโดย TIMx_CCR1 and TIMx_CCR5
     –   ถ้า GC5C2 ถูกเซ็ต, OC2REFC จะถูกควบคุมโดย TIMx_CCR2 and TIMx_CCR5
     –   ถ้า GC5C3 ถูกเซ็ต, OC3REFC จะถูกควบคุมโดย TIMx_CCR3 and TIMx_CCR5

Combined 3-phase PWM mode สามารถถูกเลือกอย่างอิสระบน channels 1 ถึง 3 โดยการเซ็ตอย่างน้อยหนึ่งใน the 3-bits GC5C[3:1].



The TRGO2 waveform แสดงวิธีที่ the ADC สามารถถูกซิงโครไนส์บน given 3-phase PWM signals. ดูที่ Section 22.3.26: ADC synchronization สำหรับรายละเอียดเพิ่มเติม.

tha

22.3.15 Complementary outputs and dead-time insertion

The advanced-control timers (TIM1 and TIM8) สามารถเอ๊าพุท two complementary signals และจัดการ the switching-off และ the switching-on instants ของ the outputs

time นี้รู้โดยทั่วไปว่าเป็น dead-time และคุณต้องปรับมันขึ้นอยู่กับ the devices ที่คุณต่อกับ the outputs และคุณลักษณะของมัน (intrinsic delays ของ level-shifters, delays เนื่องจาก power switches...)

คุณสามารถเลือก the polarity ของ the outputs (main output OCx หรือ complementary OCxN) เป็นอิสระสำหรับแต่ละ output. นี้ถูกทำโดยการเขียนไปยัง the CCxP และ CCxNP bits ใน the TIMx_CCER register

The complementary signals OCx and OCxN ถูกทำให้ทำงานโดยการรวมของหลาย control bits: the CCxE and CCxNE bits ใน the TIMx_CCER register และ the MOE, OISx, OISxN, OSSI and OSSR bits ใน the TIMx_BDTR and TIMx_CR2 registers. ดูที่ Table 147: Output control bits for complementary OCx and OCxN channels with break feature บนหน้า 727 สำหรับรายละเอียดเพิ่มเติม. โดยเฉพาะ, the dead-time ถูกทำให้ทำงานเมื่อสวิทช์ไปยัง the idle state (MOE ตกลงเป็น 0).


tha

Dead-time insertion ถูกเปิดการใช้งานโดยการเซ็ตทั้ง CCxE และ CCxNE bits, และ the MOE bit ถ้า the break circuit มีอยู่. มี one 10-bit dead-time generator สำหรับแต่ละ. จาก a reference waveform OCxREF, มันสร้าง 2 outputs OCx และ OCxN. ถ้า OCx และ OCxN เป็น active high:
•    The OCx output signal เป็นเหมือนอย่าง the reference signal ยกเว้นสำหรับ the rising edge, ซึ่งจะถูกหน่วงเวลาสอดคล้องกับ
      the reference rising edge.
•    The OCxN output signal เป็นตรงกันข้ามของ the reference signal ยกเว้นสำหรับ the rising edge, ซึ่งจะถูกหน่วงเวลา
      สอดคล้องกับ the reference falling edge

ถ้า the delay ใหญ่กว่าความกว้างของ the active output (OCx or OCxN) ดังนั้น the corresponding pulse จะไม่ถูกสร้าง.

รูปต่อไปนี้แสดงความสัมพันธ์ระหว่าง the output signals ของ the dead-time generator และ the reference signal OCxREF. (เราคิดว่า CCxP=0, CCxNP=0, MOE=1, CCxE=1 และ CCxNE=1 ในตัวอย่างเหล่านี้)




The dead-time delay เป็นเหมือนกันสำหรับแต่ละของ the channels และโปรแกรมได้ด้วย the DTG bits ใน the TIMx_BDTR register. อ้างอิงถึง Section 22.4.18: TIMx break and dead-time register (TIMx_BDTR)(x = 1, 8 ) สำหรับ delay calculation.

tha

Re-directing OCxREF to OCx or OCxN

ใน output mode (บังคับ, output compare or PWM), OCxREF สามารถถูกเปลี่ยนทิศทางไปยัง the OCx output หรือไปยัง OCxN output โดยการกำหนดค่า the CCxE และ CCxNE bits ใน the TIMx_CCER register.

นี้ยอมให้ผู้ใช้ส่ง a specific waveform (อย่างเช่น PWM หรือ static active level) บน one output ในขณะที่ตัวเสริม (the complementary) ยังคงอยู่ที่ inactive level ของมัน. ความเป็นไปได้ทางเลือกอื่นๆคือมีทั้งสอง outputs ที่ inactive level หรือทั้งสอง outputs ที่ active และเสริมด้วย dead-time.

Note: เมื่อมีเพียง OCxN ถูกเปิดการใช้งาน (CCxE=0, CCxNE=1), มันไม่ได้ถูกเสริมและกลายเป็น active ทันทีที่ OCxREF
           เป็น high. ตัวอย่างเช่น, ถ้า CCxNP=0 ดังนั้น OCxN=OCxRef. ในทางกลับกัน, เมื่อทั้ง OCx และ OCxN ถูกเปิดการใช้งาน
           (CCxE=CCxNE=1) OCx กลายเป็น active เมื่อ OCxREF เป็น high ขณะที่ OCxN ถูกเสริมและกลายเป็น active เมื่อ
           OCxREF เป็น low.

tha

22.3.16 Using the break function

วัตถุประสงค์ของ the break function คือเพื่อป้องกัน power switches ที่ขับโดย PWM signals ที่ส้รางด้วย the TIM1 and TIM8 timers. The two break inputs มักจะถูกเชื่อมต่อกับ fault outputs ของ power stages and 3-phase inverters. เมื่อถูกทำให้ทำงาน, the break circuitry จะปิด the PWM outputs และบังคับพวกมันให้เข้าสู่ a predefined safe state. จำนวนของ internal MCU events สามารถถูกเลือกเพื่อทริก an output shut-down ด้วย.

The break มี two channels. A break channel ที่รวบรวมทั้ง system-level fault (clock failure,...) และ application fault (จาก input pins), และสามารถบังคับ the outputs ให้เป็น a predefined level (อย่างใดอย่างหนึ่ง active หรือ inactive) หลังจาก a deadtime duration. A break2 channel ซึ่งรวมเฉพาะ application faults และสามารถบังคับ the outputs ให้เป็น an inactive state.

The output enable signal และ output levels during break จะขึ้นอยู่กับหลาย control bits:
     –   the MOE bit ใน TIMx_BDTR register ยอมให้เปิดใช้งาน /ปิดใช้งาน the outputs โดย software และรีเซ็ตในกรณีของ
          break หรือ break2 event.
     –   the OSSI bit ใน the TIMx_BDTR register กำหนดว่า the timer ควบคุม the output ใน inactive state หรือปล่อยการ
          ควบคุมให้กับ the GPIO controller (โดยทั่วไปต้องให้มันอยู่ใน Hi-Z mode)
     –   the OISx and OISxN bits ใน the TIMx_CR2 register ซึ่งกำลังเซ็ต the output shut-down level, อย่างใดอย่างหนึ่ง
          active หรือ inactive. The OCx and OCxN outputs ไม่สามารถถูกเซ็ตทั้งสองให้เป็น active level ในเวลาที่กำหนด , ไม่ว่า           
          ก็ตาม the OISx and OISxN values. ดูที่ Table 147: Output control bits for complementary OCx and OCxN
          channels with break feature บนหน้า 727 สำหรับรายละเอียดที่มากขึ้น.

tha

เมื่อออกจาก reset, the break circuit ถูกปิดการใช้งานและ the MOE bit เป็น low. คุณสามารถเปิดการใช้งาน the break function โดยการเซ็ต the BKE and BKE2 bits ใน the TIMx_BDTR register. The break input polarity สามารถถูกเลือกโดยการกำหนดค่า the BKP and BKP2 bits ใน the same register. BKEx และ BKPx สามารถถูกแก้ไขที่เวลาเดียวกัน. เมื่อ the BKEx และ BKPx bits ถูกเขียน, a delay ของ 1 APB clock cycle ถูกใช้ก่อนการเขียนจะเป็นผล. ด้วยเหตุนี้, มันมีความจำเป็นที่ต้องคอย 1 APB clock period เพื่อการอ่านกลับบิตอย่างถูกต้องหลังจาก the write operation

เพราะว่า MOE falling edge สามารถถูก asynchronous, a resynchronization circuit ถูกแทรกระหว่าง the actual signal (ทำงานบน the outputs) และ the synchronous control bit (ที่เข้าถึงใน the TIMx_BDTR register). ส่งผลให้เกิดบาง delays ระหว่าง the asynchronous และ the synchronous signals.  โดยเฉพาะอย่างยิ่ง, ถ้าคุณเขียน MOE เป็น 1 ในขณะที่มันเป็น low, คุณต้องใส่ a delay(dummy instruction) ก่อนการอ่านมันได้อย่างถูกต้อง. นี้ก็เพราะว่าคุณเขียน an asynchronous signal และอ่าน a synchronous signal

tha

The break (BRK) event สามารถถูกสร้างโดยสองแหล่งของ events OR เข้าด้วยกัน:
•   An external source ที่ต่อกับหนึ่งใน the BKIN pin (ตามการเลือกที่ทำใน the AFIO controller)
•   An internal source: clock failure event ที่สร้างโดย the CSS detector

The break2 (BRK2) สามารถถูกสร้างโดย an external source ที่ต่อกับหนึ่งใน the BKIN2 pin (ตามการเลือกที่ทำใน the AFIO controller).

Break events สามารถถูกสร้างโดย software โดยใช้ BG and B2G bits ใน the TIMx_EGR register ได้อีกด้วย. The software break generation โดยใช้ BG and BG2 ทำงานได้ไม่ว่าก็ตาม the BKE and BKE2 enable bits values.



Note: An asynchronous (clockless) operation ถูกรับประกันเฉพาะเมื่อ the programmable filter ถูกปิดใช้งาน. ถ้ามันถูกเปิดใช้
          งาน, a fail safe clock mode (ตัวอย่างเช่นโดยการใช้ the internal PLL and/or the CSS) ต้องถูกใช้เพื่อรับประกันว่า break
          events จะถูกจัดการ.