STM32F7 5 Reset and clock control (RCC)

Started by tha, September 16, 2022, 01:43:08 PM

Previous topic - Next topic

tha

5.2.8 RTC/AWU clock

เมื่อ the RTCCLK clock source ถูกเลือกแล้ว, วิธีเดียวที่เป็นไปได้ในการแก้ไขการเลือกคือการรีเซ็ต the power domain

The RTCCLK clock source สามารถเป็นอย่างใดอย่างหนึ่ง the HSE 1 MHz (HSE ที่หารโดย a programmable prescaler), the LSE หรือ the LSI clock. นี้ถูกเลือกโดยการโปรแกรม the RTCSEL[1:0] bits ใน the RCC backup domain control register (RCC_BDCR) และ the RTCPRE[4:0] bits ใน RCC clock configuration register (RCC_CFGR). การเลือกนี้ไม่สามารถถูกแก้ไขโดยปราศจากการรีเซ็ต the Backup domain.

ถ้า the LSE ถูกเลือกเป็น the RTC clock, the RTC จะทำงานตามปกติถ้า the backup หรือ the system supply หายไป. ถ้า the LSI ถูกเลือกเป็น the AWU clock, the AWU state จะไม่ถูกรับประกันถ้า the system supply หายไป. ถ้า the HSE oscillator ที่หารโดย a value ระหว่าง 2 และ 31 ถูกใช้เป็น the RTC clock, the RTC state จะไม่ถูกรับประกันถ้า the backup หรือ the system supply หายไป.

The LSE clock อยู่ใน the Backup domain, ในขณะที่ the HSE and LSI clocks ไม่อยู่. ผลที่ตามมา:
•   ถ้า LSE ถูกเลือกเป็น the RTC clock:
     –   The RTC จะทำงานต่อไปถึงแม้ว่า the VDD supply ถูกปิด, โดยจัดให้มี the VBAT supply ถูกรักษาไว้.
     –   The RTC ยังคงให้สัญญานนาฬิกาและทำหน้าที่ภายใต้ system reset.
•   ถ้า LSI ถูกเลือกเป็น the Auto-wakeup unit (AWU) clock:
     –   The AWU state จะไม่ถูกรับประกันถ้า the VDD supply ถูกปิด. ดูที่ Section 5.2.5: LSI clock บนหน้า 139 สำหรับราย
          ละเอียดที่มากขึ้นเกี่ยวกับ LSI calibration.
•   ถ้า the HSE clock ถูกใช้เป็น the RTC clock:
     –   The RTC state จะไม่ถูกรับประกันถ้า the VDD supply ถูกปิดหรือถ้า the internal voltage regulator ถูกปิด (เอา power
          ออกจาก the 1.2 V domain) และเมื่อเข้าสู่ใน Stop mode ด้วย

Note: เพื่ออ่าน the RTC calendar register เมื่อ the APB1 clock frequency น้อยกว่าเจ็ดเท่าของ the RTC clock frequency (fAPB1 < 7xfRTCLCK), the software ต้องอ่าน the calendar time and date registers สองครั้ง. The data ถูกต้องถ้า the second read เข้าถึงไปยัง RTC_TR ให้ผลลัพธ์เหมือนกันกับค่าอ่านแรก. ถ้าเป็นอย่างอืน a third read access ต้องถูกดำเนินการ.

tha

5.2.9 Watchdog clock

ถ้า the Independent watchdog (IWDG) ถูกสตาร์ทโดยอย่างใดอย่างหนึ่ง hardware option หรือ software access , the LSI oscillator ถูกบังคับให้ ON และไม่สามารถถูกปิดการใช้งาน. หลังจาก the LSI oscillator temporization, the clock ถูกจัดให้กับ the IWDG.

tha

5.2.10 Clock-out capability

สอง microcontroller clock output (MCO) pins มีให้ใช้งาน:
•   MCO1
     ผู้ใช้สามารถเอาพุทสี่ clock sources ที่ต่างกันลงบน the MCO1 pin (PA8) โดยใช้ the configurable prescaler (จาก 1 ถึง 5):
     –   HSI clock
     –   LSE clock
     –   HSE clock
     –   PLL clock
     The desired clock source ถูกเลือกโดยใช้ the MCO1PRE[2:0] and MCO1[1:0] bits ใน the RCC clock configuration
     register (RCC_CFGR).
•   MCO2
     ผู้ใช้สามารถเอาพุทสี่ clock sources ที่ต่างกันลงบน the MCO2 pin (PC9) โดยใช้ the configurable prescaler (จาก 1 ถึง 5):
     –   HSE clock
     –   PLL clock
     –   System clock (SYSCLK)
     –   PLLI2S clock
     The desired clock source ถูกเลือกโดยใช้ the MCO2PRE[2:0] and MCO2 bits ใน the RCC clock configuration
     register (RCC_CFGR).

สำหรับ the different MCO pins, the corresponding GPIO port ต้องถูกโปรแกรมใน alternate function mode.


tha

5.2.11 Internal/external clock measurement using TIM5/TIM11

เป็นไปได้ที่จะวัดทางอ้อม the frequencies ของทุก on-board clock source generators โดยวิธีของ the input capture ของ TIM5 channel4 and TIM11 channel1 ดังแสดงใน Figure 15 and Figure 16.

Internal/external clock measurement using TIM5 channel4

TIM5 มี an input multiplexer ซึ่งยอมให้เลือกได้ว่า the input capture จะถูกทริกโดย the I/O หรือโดย an internal clock. การเลือกนี้ถูกดำเนินการผ่านทาง the TI4_RMP [1:0] bits ใน the TIM5_OR register.

วัตถุประสงค์หลักของการมี the LSE เชื่อมต่อถึง the channel4 input capture คือให้สามารถวัด the HSI ได้อย่างแม่นยำ (นี้ต้องการให้ the HSI ถูกใช้เป็น the system clock source). จำนวนของ HSI clock counts ระหว่างขอบที่ต่อเนื่องกันของ the LSE signal จัดให้มี a measurement ของ the internal clock period. ใช้ประโยชน์จากความแม่นยำสูงของ LSE crystals (โดยทั่วไปคือไม่กี่สิบ ppm) เราสามารถตัดสิน the internal clock frequency ด้วยความละเอียดเดี่ยวกัน, และตัดแต่ง the source เพื่อชดเชยสำหรับ manufacturing-process และ/หรือ temperature- and voltage-related frequency deviations.

tha

The HSI oscillator มี user-accessible calibration bits โดยเฉพาะสำหรับวัตถุประสงค์นี้.

แนวคิดพื้นฐานประกอบด้วยการจัดให้มีการวัดความสัมพัทธ์ (เช่น  HSI/LSE ratio): ความแม่นยำจึงเชื่อมโยงอย่างแน่นหนากับอัตราส่วนระหว่าง the two clock sources. ยิ่ง the ratio ใหญ่ขึ้น, การวัดก็จะดีขึ้น.

นอกจากนี้ยังสามารถวัด the LSI frequency: สิ่งนี้มีประโยชน์สำหรับ applications ที่ไม่มี a crystal. The ultra-low-power LSI oscillator มี a large manufacturing process deviation: โดยการวัดมันเทียบกับ the HSI clock source, มันเป็นไปได้ที่จะตัดสินความถี่ของมันด้วยความเที่ยงตรงของ the HSI. ค่ามีวัดสามารถถูกใช้เพื่อให้มี RTC time base timeouts ที่แม่นยำมากขึ้น (เมื่อ LSI ถูกใช้เป็น the RTC clock source) และ/หรือ an IWDG timeout ด้วยความแม่นยำที่ยอมรับได้.

tha

ใช้ขั้นตอนต่อไปนี้เพื่อวัด the LSI frequency:
1.   เปิดใช้งาน the TIM5 timer และกำหนดค่า channel4 ใน Input capture mode.
2.   บิตนี้จะเซ็ต the TI4_RMP bits ใน the TIM5_OR register เป็น 0x01 เพื่อเชื่อมต่อ the LSI clock ภายในไปยัง TIM5 channel4
      input capture สำหรับ calibration purposes.
3.   วัด the LSI clock frequency โดยใช้ the TIM5 capture/compare 4 event หรือ interrupt.
4.   ใช้ the measured LSI frequency เพื่ออัฟเดต the prescaler ของ the RTC ขึ้นอยู่กับ the desired time base และ/หรือเพื่อ
      คำนวร the IWDG timeout.


tha

Internal/external clock measurement using TIM11 channel1

TIM11 มี an input multiplexer ซึ่งยอมให้เลือกว่า the input capture จะถูกทริกโดย the I/O หรือโดย an internal clock. การเลือกนี้ถูกดำเนินการผ่านทาง TI1_RMP [1:0] bits ใน the TIM11_OR register. The HSE_RTC clock (HSE ที่หารด้วย a programmable prescaler) ถูกเชื่อมต่อถึง channel 1 input capture เพื่อให้มีการแสดงให้เห็นโดยคร่าวๆของ the external crystal frequency. นี้ต้องการให้ the HSI เป็น the system clock source. ซึ่งสามารถเป็นประโยชน์สำหรับกรณีเพื่อให้แน่ใจว่าสอดคล้องกับ the IEC 60730/IEC 61335 standards ซึ่งจำเป็นต้องสามารถตัดสิน harmonic หรือ subharmonic frequencies (–50/+100% deviations).


tha

5.2.12 Peripheral clock enable register (RCC_AHBxENR, RCC_APBxENRy)

แต่ละ peripheral clock สามารถถูกเปิดใช้งานโดย the xxxxEN bit ของ the RCC_AHBxENR หรือ RCC_APBxENRy registers.

เมื่อ the peripheral clock ไม่ทำงาน, the peripheral registers read or write accesses จะไม่รองรับ.The peripheral enable bit มี a synchronization mechanism เพื่อสร้าง a glitch free clock สำหรับ the peripheral.

หลังจาก the enable bit ถูกเซ็ต, มันจะมี a 2 peripheral clock cycles delay ก่อนที่ the clock จะทำงาน.

ข้อควรระวัง: หลังจากเปิดใช้งาน the clock สำหรับ a peripheral, software ต้องรอเป็นเวลา a 2 peripheral clock cycles delay ก่อนที่จะเข้าถึง the peripheral registers.