STM32F7 5 Reset and clock control (RCC)

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

Previous topic - Next topic

tha

•   The RTC clock ซึ่งมาจากหนึ่งใน the following sources:
     –   LSE clock
     –   LSI clock
     –   HSE clock ที่หารด้วย 32
•   The IWDG clock ซึ่งเป็น the LSI clock เสมอ.
•   The timer clock frequencies ถูกเซ็ตโดยอัตโนมัติโดย hardware. มีสองกรณีขึ้นอยู่กับค่าของ TIMPRE bit ใน RCC_CFGR
     register:
     –   ถ้า TIMPRE bit ใน RCC_DCKCFGR1 register ถูกรีเซ็ต:
          ถ้า the APB prescaler ถูกกำหนดค่าแฟคเตอร์ตัวหารเท่ากับ 1, the timer clock frequencies (TIMxCLK) จะถูกเซ็ตถึง
          PCLKx. ถ้าเป็นอย่างอื่น, the timer clock frequencies จะเป็นสองเท่าของ the frequency of the APB domain ซึ่ง the
          timers ถูกต่อถึง: TIMxCLK = 2xPCLKx.
     –   ถ้า TIMPRE bit ใน RCC_DCKCFGR1 register ถูกเซ็ต:
          ถ้า the APB prescaler ถูกกำหนดค่าแฟคเตอร์ตัวหารเท่ากับ 1, 2 หรือ 4, the timer clock frequencies (TIMxCLK) จะถูก
          เซ็ตถึง HCLK. ถ้าเป็นอย่างอื่น, the timer clock frequencies จะเป็นสี่เท่าของ the frequency of the APB domain ซึ่ง the
          timers ถูกต่อถึง: TIMxCLK = 4xPCLKx.

The RCC ป้อน the external clock of the Cortex System Timer (SysTick) ด้วย the AHB clock (HCLK) ที่หารด้วย 8. The SysTick สามารถทำงานด้วยอย่างใดอย่างหนึ่ง clock นี้หรือด้วย the Cortex clock(HCLK), กำหนดค่าได้ใน the SysTick control and status register.

FCLK ทำงานเป็น Cortex®-M7 free-running clock. สำหรับรายละเอียดที่มากขึ้น, ดูที่ the Cortex®-M7 technical reference manual.

tha

5.2.1 HSE clock

The high speed external clock signal (HSE) สามารถถูกสร้างจาก two possible clock sources:

•    HSE external crystal/ceramic resonator
•    HSE user external clock

The resonator และ the load capacitors ต้องถูกใส่ให้ใกล้ที่สุดเท่าที่จะทำได้เข้ากับ the oscillator pins เพื่อทำให้ output distortion ต่ำสุดและสตาร์ทอัฟ stabilization time. The loading capacitance values ต้องถูกปรับให้สอดคล้องกับ the selected oscillator.



External source (HSE bypass)

ในโหมดนี้, an external clock source ต้องถูกจัดให้มี. โหมดนี้สามารถถูกเลือกโดยการเซ็ต the HSEBYP และ HSEON bits ใน the Clock control register (RCC_CR). The external clock signal (square, sinus หรือ triangle) ที่มี ~50% duty cycle ต้องขับ the OSC_IN pin ในขณะที่ the OSC_OUT pin ถูกปล่อยให้เป็นอิมพิแด๊นท์สูง (hi-Z). ดู Figure 14.

External crystal/ceramic resonator (HSE crystal)

The HSE มีข้อได้เปรียบในการสร้าง a very accurate rate บน the main clock

The associated hardware configuration ถูกแสดงใน Figure 14. ดูที่ the electrical characteristics section ของ the datasheet สำหรับรายละเอียดที่มากขึ้น

The HSERDY flag ใน the Clock control register (RCC_CR) จะแสดงว่า the high-speed external oscillator มีความเสถียรหรือไม่. ที่ startup, the clock จะไม่ถูกปล่อยออกมาจนกว่าบิตนี้จะถูกเซ็ตโดย hardware. An interrupt สามารถถูกสร้างขึ้นถ้าเปิดการใช้งานใน the Clock interrupt register (RCC_CIR).

The HSE Crystal สามารถถูก switched on และ off โดยใช้ the HSEON bit ใน the Clock control register (RCC_CR).

tha

5.2.2 HSI clock

The HSI clock signal ถูกสร้างจาก an internal 16 MHz RC Oscillator และสามารถถูกใช้โดยตรงเป็น a system clock หรือถูกใช้เป็น PLL input.

The HSI RC oscillator มีข้อได้เปรียบของการจัดให้มี a clock source ที่ราคาต่ำ (ไม่มีส่วนประกอบภายนอก). มันยังมี startup time ที่เร็วกว่า the HSE crystal oscillator อย่างไรก็ตาม, แม้ด้วยการสอบเทียบ the frequency ก็ยังมีความแม่นยำที่น้อยกว่า an external crystal oscillator หรือ ceramic resonator.

Calibration

RC oscillator frequencies สามารถแตกต่างกันไปจากชิปไปยังชิปอื่นเนื่องจาก manufacturing process variations, นี่คือสาเหตุที่แต่ละ device ถูกปรับเทียบจากโรงงานโดย ST เพื่อความแม่นยำ 1% ที่ TA = 25 ° C.

หลังจาก reset, the factory calibration value ถูกโหลดลงใน the HSICAL[7:0] bits ใน the Clock control register (RCC_CR).

หาก the application อยู่ภายใต้ voltage หรือ temperature variations นี้อาจมีผลกระทบต่อ the RC oscillator speed. คุณสามารถตัดแต่ง the HSI frequency ใน the application โดยใช้ the HSITRIM[4:0]bits ใน the Clock control register (RCC_CR).

The HSIRDY flag ใน the Clock control register (RCC_CR) จะแสดงว่า the HSI RC มีความเสถียรหรือไม่. ที่ startup, the HSI RC output clock จะไม่ถูกปล่อยออกมาจนกว่าบิตนี้ถูกเซ็ตโดย hardware.

The HSI RC สามารถถูก switched on และ off โดยใช้ the HSION bit ใน the Clock control register (RCC_CR).


tha

5.2.3 PLL

The devices มีคุณลักษณะสาม PLLs:
•   A main PLL (PLL) ที่ให้สัญญานนาฬิกาโดย the HSE or HSI oscillator และมีคุณลักษณะ two different output clocks:
     –   The first output ถูกใช้สร้าง the high speed system clock (สูงถึง 216 MHz)
     –   The second output ถูกใช้สร้าง 48MHz clock สำหรับ the USB OTG FS, SDMMC และ RNG.
•   PLLI2S ถูกใช้สร้าง an accurate clock เพื่อให้สำเร็จ high-quality audio performance บน the I2S, SAIs และ SPDIFRX
     interfaces.
•   PLLSAI ถูกใช้สร้าง clock สำหรับ SAIs intefraces, LCD-TFT clock และ the 48MHz (PLLSAI48CLK) ที่สามารถถูกเลือกสำหรับ
     the USB OTG FS, SDMMC และ RNG.

เนื่องจาก the main-PLL configuration parameters ไม่สามารถถูกเปลี่ยนได้เมื่อ PLL ถูกเปิดใช้งานแล้ว, ขอแนะนำให้กำหนดค่า PLL ก่อนการเปิดใช้งานมัน (การเลือก the HSI or HSE oscillator เป็น PLL clock source, และการกำหนดค่า division factors M, N, P, and Q).

The PLLI2S and PLLSAI ใช้ the same input clock เป้น PLL (PLLM[5:0] and PLLSRC bits ใช้ร่วมกันทั้งสอง PLLs). อย่างไรก็ตาม, the PLLI2S and PLLSAI มี enable/disable and division factors (N and R) configuration bits โดยเฉพาะ. ทันทีที่ the PLLI2S and PLLSAI ถูกเปิดใช้งาน, the configuration parameters ไม่สามารถถูกเปลี่ยน.

The three PLLs ถูกปิดใช้งานโดย hardware เมื่อเข้าสู่ Stop and Standby modes, หรือเมื่อ an HSE failure เกิดขึ้นเมื่อ HSE or PLL (ที่ให้สัญญานนาฬิกาโดย HSE) ถูกใช้เป็น system clock. RCC PLL configuration register (RCC_PLLCFGR),RCC clock configuration register(RCC_CFGR), และ RCC dedicated clocks configuration register (RCC_DCKCFGR1) สามารถถูกใช้กำหนดค่า PLL, PLLI2S, and PLLSAI.

tha

5.2.4 LSE clock

The LSE crystal ถูกสร้างจาก a 32.768 kHz Low Speed External crystal หรือ ceramic resonator.มันมีข้อได้เปรียบที่จัดให้มี a low-power แต่ highly accurate clock จ่ายไปยัง the real-time clock peripheral (RTC) สำหรับ clock/calendar หรือ timing functions อื่นๆ.

The LSE crystal ถูก switched on และ off โดยใช้ the LSEON bit ใน Backup domain control register (RCC_BDCR).

The LSERDY flag ใน the Backup domain control register (RCC_BDCR) จะแสดงว่า the LSE crystal มีความเสถียรหรือไม่. ที่ startup, the LSE crystal output clock signal จะไม่ถูกปล่อยออกมาจนกว่าบิตนี้ถูกเซ็ตโดย hardware. An interrupt สามารถถูกสร้างขึ่นถ้าเปิดการใช้งานใน the Clock interrupt register (RCC_CIR).

External source (LSE bypass)

ในโหมดนี้, an external clock source ต้องถูกจัดให้มี. มันสามารถมีความถี่ขึ้นไปถึง 1 MHz. คุณเลือกโหมดนี้โดยการเซ็ต the LSEBYP และ LSEON bits ใน the Backup domain control register (RCC_BDCR). The external clock signal (square, sinus หรือ triangle) ด้วยประมาณ ~50% duty cycle ต้องขับ  the OSC32_IN pin ในขณะที่ the OSC32_OUT pin ควรถูกปล่อยให้เป็นอิมพิแด๊นท์สูง (hi-Z). ดู Figure 14.

tha

5.2.5 LSI clock

The LSI RC ทำหน้าที่เป็น an low-power clock source ที่สามารถทำงานได้ต่อไปใน Stop และ Standby mode สำหรับ the independent watchdog (IWDG) และ Auto-wakeup unit (AWU). The clock frequency อยู่ที่ประมาณ 32 kHz. สำหรับรายละเอียดที่มากขึ้น, ดูที่ the electrical characteristics section ของ the datasheets.

The LSI RC สามารถถูก switched on และ off โดยใช้ the LSION bit ใน the Control/status register (RCC_CSR).

The LSIRDY flag ใน the Control/status register (RCC_CSR) จะแสดงว่า the low-speed internal oscillator มีความเสถียรหรือไม่. ที่ startup, the clock จะไม่ถูกปล่อยออกมาจนกว่าบิตนี้ถูกเซ็ตโดย hardware. An interrupt สามารถถูกสร้างขึ่นถ้าเปิดการใช้งานใน the Clock interrupt register (RCC_CIR).

tha

5.2.6 System clock (SYSCLK) selection

หลังจาก a system reset, the HSI oscillator ถูกเลือกเป็น system clock. เมื่อ a clock source ถูกใช้โดยตรงหรือผ่านทาง the PLL เป็น system clock, เป็นไปไม่ได้ที่จะหยุดมัน.

การสวิทช์จาก clock source หนึ่งไปยัง clock source อื่นจะเกิดขึ้นเฉพาะถ้า the target clock source พร้อมแล้วเท่านั้น (clock มีเสถียรหลังจาก startup delay หรือ PLL locked). หาก a clock source ซึ่งยังไม่พร้อมถูกเลือก, การสวิทช์จะเกิดขึ้นเมื่อ the clock source พร้อมแล้ว. Status bits ใน the RCC clock control register (RCC_CR) จะแสดงว่า clock(s) พร้อมแล้วและว่า clock ถูกใช้ในขณะนี้เป็น system clock

tha

5.2.7 Clock security system (CSS)

Clock Security System สามารถถูกทำให้ทำงานโดย software. ในกรณีนี้, the clock detector ถูกเปิดการใช้งานหลังจาก the HSE oscillator startup delay, และปิดการใช้งานเมื่อ oscillator นี้ถูกหยุด.

ถ้า a failure ถูกตรวจพบบน the HSE clock, oscillator นี้จะถูกปิดการใช้งานโดยอัตโนมัติ, a clock failure event ถูกส่งไปยัง the break input ของ the advanced-control timers (TIM1 and TIM8) และ an interrupt ถูกสร้างขึ้นเพื่อแจ้ง the software เกี่ยวกับความล้มเหลวนี้ (Clock Security System Interrupt CSSI), ยอมให้ the MCU ดำเนินการ rescue operations. The CSSI ถูกเชื่อมต่อถึง the Cortex®-M7 NMI (Non-Maskable Interrupt) exception vector.

Note: เมื่อ the CSS ถูกเปิดการใช้งานม ถ้า the HSE clock เกิดล้มเหลว, the CSS จะสร้าง an interrupt, ซึ่งเป้นเหตุให้เกิดการสร้างขึ้นโดยอัตโนมัติของ an NMI. The NMI จะถูกดำเนินการต่อไปอย่างไม่มีกำหนดเว้นแต่ the CSS interrupt pending bit ถูก cleared. เป็นผลให้,  the application ต้องเคลียร์ the CSS interrupt ใน the NMI ISR โดยการเซ็ต the CSSC bit ใน the Clock interrupt register(RCC_CIR).

ถ้า the HSE oscillator ถูกใช้โดยตรงหรือโดยอ้อมเป็น the system clock (โดยอ้อมหมายถึงว่ามันถูกใช้โดยตรงเป็น PLL input clock, และ the PLL clock นั้นป็น system clock), a failure ถูกตรวจพบ, ดังนั้น the system clock สวิทช์ไปยัง the HSI oscillator และ the HSE oscillator ถูกปิดการใช้งาน.

ถ้า the HSE oscillator clock เคยเป็น the clock source ของ PLL ที่ใช้เป็น the system clock เมื่อ the failure เกิดขึ้น, PLL จะถูกปิดใช้งานด้วย. ในกรณีนี้, ถ้า the PLLI2S or PLLSAI เคยถูกเปิดใช้งาน, มันจะถูกปิดใช้งานเมื่อ the HSE fails ด้วย.