STM32F7 5 Reset and clock control (RCC)

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

Previous topic - Next topic

tha

5.3 RCC registers

ดูที่ Section 1.2: List of abbreviations for registers สำหรับรายการตัวย่อที่ใช้ใน register descriptions.

5.3.1 RCC clock control register (RCC_CR)

Address offset: 0x00
Reset value: 0x0000 XX83 โดยที่ X ไม่ถูกกำหนด.
Access: ไม่มี wait state, word, half-word and byte access



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

Bit 29 PLLSAIRDY: PLLSAI clock ready flag
     เซ็ตโดย hardware เพื่อแสดงให้เห็นว่า the PLLSAI ถูกล็อค.
     0: PLLSAI unlocked
     1: PLLSAI locked

Bit 28 PLLSAION: PLLSAI enable
     เซ็ตและเคลียร์โดย software เพื่อเปิดการใช้งาน PLLSAI.
     เคลียร์โดย hardware เมื่อเข้าสู่ Stop or Standby mode.
     0: PLLSAI OFF
     1: PLLSAI ON

Bit 27 PLLI2SRDY: PLLI2S clock ready flag
     เซ็ตโดย hardware เพื่อแสดงให้เห็นว่า the PLLI2S ถูกล็อค.
     0: PLLI2S unlocked
     1: PLLI2S locked

Bit 26 PLLI2SON: PLLI2S enable
     เซ็ตและเคลียร์โดย software เพื่อเปิดการใช้งาน PLLI2S.
     เคลียร์โดย hardware เมื่อเข้าสู่ Stop or Standby mode.
     0: PLLI2S OFF
     1: PLLI2S ON

Bit 25 PLLRDY: Main PLL (PLL) clock ready flag
     เซ็ตโดย hardware เพื่อแสดงให้เห็นว่า the PLL ถูกล็อค.
     0: PLL unlocked
     1: PLL locked

Bit 24 PLLON: Main PLL (PLL) enable
     เซ็ตและเคลียร์โดย software เพื่อเปิดการใช้งาน  PLL.
     เคลียร์โดย hardware เมื่อเข้าสู่ Stop หรือ Standby mode. บิตนี้ไม่สามารถถูก reset ถ้า the PLL clock ถูกใช้เป็น system
     clock.
     0: PLL OFF
     1: PLL ON

tha

Bit 19 CSSON: Clock security system enable
     เซ็ตและเคลียร์โดย software เพื่อเปิดการใช้งาน the clock security system. เมื่อ CSSON ถูกเซ็ต, the clock detector จะถูก
     เปิดใช้งานโดย hardware เมื่อ the HSE oscillator พร้อมแล้ว, และจะปิดใช้งานโดย hardware ถ้า a HSE clock failure ถูกตรวจ
     จับได้.
     0: Clock security system OFF (Clock detector OFF)
     1: Clock security system ON (Clock detector ON ถ้า HSE oscillator เสถียร, OFF ถ้าไม่)

Bit 18 HSEBYP: External high-speed clock bypass
     เซ็ตและเคลียร์โดย software เพื่อข้ามผ่าน the oscillator ด้วย an external clock. The external clock ต้องถูกเปิดใช้งานด้วย
     the HSEON bit เซ็ต, เพื่อถูกใช้โดย the device. The HSEBYP bit สามารถถูกเขียนได้เฉพาะถ้า the HSE oscillator ถูกปิดใช้
     งานเท่านั้น.
     0: HSE oscillator ไม่ถูกข้ามผ่าน
     1: HSE oscillator ถูกข้ามผ่านด้วย an external clock

Bit 17 HSERDY: External high-speed clock ready flag
     เซ็ตโดย hardware เพื่อแสดงให้เห็นว่า the HSE oscillator มีความเสถียร. หลังจาก the HSEON bit ถูกเคลียร์, HSERDY จะไป
     เป็น low หลังจาก 6 HSE oscillator clock cycles.
     0: HSE oscillator not ready
     1: HSE oscillator ready

Bit 16 HSEON: HSE clock enable
     เซ็ตและเคลียร์โดย software.
     เคลียร์โดย hardware เพื่อหยุด the HSE oscillator เมื่อเข้าสู่ Stop หรือ Standby mode. บิตนี้ไม่สามารถถูกรีเซ็ตถ้า the HSE
     oscillator ถูกใช้โดยตรงหรือโดยอ้อมเป็น the system clock.
     0: HSE oscillator OFF
     1: HSE oscillator ON

tha

Bits 15:8 HSICAL[7:0]: Internal high-speed clock calibration
     บิตเหล่านี้ถูกเริ่มต้นโดยอัตโนมัติที่ startup.

Bits 7:3 HSITRIM[4:0]: Internal high-speed clock trimming
     บิตเหล่านี้จัดให้มี an additional user-programmable trimming value ที่ถูกเพิ่มให้กับ the HSICAL[7:0] bits. มันสามารถถูก
     โปรแกรมเพื่อปรับการเปลี่ยนแปลงใน voltage และ temperature ที่มีผลต่อ the frequency ของ the internal HSI RC.

Bit 2 Reserved, must be kept at reset value.

Bit 1 HSIRDY: Internal high-speed clock ready flag
     เซ็ตโดย hardware เพื่อแสดงให้เห็นว่า the HSI oscillator เสถียร. หลังจาก the HSION bit ถูกเคลียร์, HSIRDY จะลงไปเป็น low
     หลังจาก 6 HSI clock cycles.
     0: HSI oscillator not ready
     1: HSI oscillator ready

Bit 0 HSION: Internal high-speed clock enable
     เซ็ตและเคลียร์โดย software.
     เซ็ตโดย hardware เพื่อบังคับ the HSI oscillator ON เมื่อออกจาก Stop หรือ Standby mode หรือในกรณีของความล้มเหลวของ
     the HSI oscillator ที่ใช้โดยตรงหรือโดยอ้อมเป็น system clock. บิตนี้ไม่สามารถถูก reset ถ้า the HSI oscillator ถูกใช้โดยตรง
     หรือโดยอ้อมเป็น system clock.
     0: HSI oscillator OFF
     1: HSI oscillator ON


tha

5.3.2 RCC PLL configuration register (RCC_PLLCFGR)

Address offset: 0x04
Reset value: 0x2400 3010
Access: no wait state, word, half-word and byte access.

register นี้ถูกใช้เพื่อกำหนดค่า the PLL clock outputs สอดคล้องกับ the formulas:
•   f(VCO clock) = f(PLL clock input) × (PLLN / PLLM)
•   f(PLL general clock output) = f(VCO clock) / PLLP
•   f(USB OTG FS, SDMMC, RNG clock output) = f(VCO clock) / PLLQ



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

Bits 27:24 PLLQ[3:0]: Main PLL (PLL) division factor for USB OTG FS, SDMMC and random number generator clocks
     เซ็ตและเคลียร์โดย software เพื่อควบคุมความถี่ของ USB OTG FS clock, the random number generator clock and the
     SDMMC clock. บิตเหล่านี้ควรถูกเขียนเฉพาะถ้า PLL ถูกปิดการใช้งาน.

     Caution: The USB OTG FS ต้องการ a 48 MHz clock เพื่อทำงานอย่างถูกต้อง. The SDMMC and the random number
                      generator ต้องการ a frequency ที่ต่ำกว่าหรือเท่ากับ 48 MHz เพื่อทำงานอย่างถูกต้อง.

     USB OTG FS clock frequency = VCO frequency / PLLQ with 2 ≤ PLLQ ≤ 15
     0000: PLLQ = 0, wrong configuration
     0001: PLLQ = 1, wrong configuration
     0010: PLLQ = 2
     0011: PLLQ = 3
     0100: PLLQ = 4
     ...
     1111: PLLQ = 15

Bit 23 Reserved, must be kept at reset value.

Bit 22 PLLSRC: Main PLL(PLL) and audio PLL (PLLI2S) entry clock source
     เซ็ตและเคลียร์โดย software เพื่อเลือก PLL and PLLI2S clock source. บิตนี้สามารถถูกเขียนเฉพาะเมื่อ PLL and PLLI2S ถูกปิด
     การใช้งาน.
     0: HSI clock ถูกเลือกเป็น PLL and PLLI2S clock entry
     1: HSE oscillator clock ถูกเลือกเป็น  PLL and PLLI2S clock entry

Bits 21:18 Reserved, must be kept at reset value.

tha

Bits 17:16 PLLP[1:0]: Main PLL (PLL) division factor for main system clock
      เซ็ตและเคลียร์โดย software เพื่อควบคุม the frequency ของ the general PLL output clock. บิตเหล่านี้สามารถถูกเขียนเฉพาะ
      ถ้า PLL ถูกปิดใช้งาน.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องไม่เกิน 216 MHz บนโดเมนนี้.
     PLL output clock frequency = VCO frequency / PLLP with PLLP = 2, 4, 6, or 8
     00: PLLP = 2
     01: PLLP = 4
     10: PLLP = 6
     11: PLLP = 8

Bits 14:6 PLLN[8:0]: Main PLL (PLL) multiplication factor for VCO
     เซ็ตและเคลียร์โดย software เพื่อควบคุมแฟ็คเตอร์ตัวคูณของ the VCO. บิตเหล่านี้สามารถถูกเขียนเฉพาะถ้า PLL ถูกปิดใช้งาน.. เฉพาะ
     half-word and word accesses ถูกยอมให้เขียนบิตเหล่านี้.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องเพื่อให้แน่ใจว่า the VCO output frequency อยู่ระหว่าง 100 and 432
                      MHz.
     VCO output frequency = VCO input frequency × PLLN with 50 ≤ PLLN ≤ 432
     000000000: PLLN = 0, wrong configuration
     000000001: PLLN = 1, wrong configuration
     ...
     000110010: PLLN = 50
     ...
     001100011: PLLN = 99
     001100100: PLLN = 100
     ...
     110110000: PLLN = 432
     110110001: PLLN = 433, wrong configuration
     ...
     111111111: PLLN = 511, wrong configuration
Note: ระหว่าง 50 and 99, multiplication factors สามารถเป็นได้สำหรับ VCO input frequency ที่สูงกว่า 1 MHz. อย่างไรก็ตาม
          ต้องใช้ความระมัดระวังเพื่อให้ได้ the minimum VCO output frequency ตามที่ระบุไว้ข้างบน


Bits 5:0 PLLM[5:0]: Division factor for the main PLLs (PLL, PLLI2S and PLLSAI) input clock
      เซ็ตและเคลียร์โดย software เพื่อหาร the PLL and PLLI2S input clock ก่อน the VCO. บิตนี้สามารถถูกเขียนเฉพาะเมื่อ PLL
      and PLLI2S ถูกปิดการใช้งาน.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องเพื่อให้แน่ใจว่า the VCO input frequency มีช่วงจาก 1 ถึง 2 MHz. ขอ
                      แนะนำให้เลือกความถี่ 2 MHz เพื่อจำกัด PLL jitter.
     VCO input frequency = PLL input clock frequency / PLLM with 2 ≤ PLLM ≤ 63
     000000: PLLM = 0, wrong configuration
     000001: PLLM = 1, wrong configuration
     000010: PLLM = 2
     000011: PLLM = 3
     000100: PLLM = 4
     ...
     111110: PLLM = 62
     111111: PLLM = 63

tha

5.3.3 RCC clock configuration register (RCC_CFGR)

Address offset: 0x08
Reset value: 0x0000 0000
Access: 0 ≤ wait state ≤ 2, word, half-word and byte access
1 หรือ 2 wait states ถูกใส่เฉพาะถ้า the access เกิดขึ้นในระหว่าง a clock source สลับ.



Bits 31:30 MCO2[1:0]: Microcontroller clock output 2
     เซ็ตและเคลียร์โดย software. Clock source selection อาจสร้าง glitches บน MCO2. ขอแนะนำอย่างยิ่งให้กำหนดค่าบิตเหล่านี้
     เฉพาะหลังจากรีเซ็ตก่อนการเปิดใช้งาน the external oscillators and the PLLs.
     00: System clock (SYSCLK) ถูกเลือก
     01: PLLI2S clock selected
     10: HSE oscillator clock selected
     11: PLL clock selected

Bits 27:29 MCO2PRE: MCO2 prescaler
     เซ็ตและเคลียร์โดย software เพื่อกำหนดค่า the prescaler ของ the MCO2. การแก้ไขของ prescaler นี้อาจสร้าง glitches บน
     MCO2. ขอแนะนำอย่างยิ่งให้เปลี่ยน prescaler  นี้เฉพาะหลังจากรีเซ็ตก่อนการเปิดใช้งาน the external oscillators and the PLLs.
     0xx: no division
     100: หารด้วย 2
     101: division by 3
     110: division by 4
     111: division by 5

Bits 24:26 MCO1PRE: MCO1 prescaler
     เซ็ตและเคลียร์โดย software เพื่อกำหนดค่า the prescaler ของ the MCO1. การแก้ไขของ prescaler นี้อาจสร้าง glitches บน
     MCO1. ขอแนะนำอย่างยิ่งให้เปลี่ยน prescaler  นี้เฉพาะหลังจากรีเซ็ตก่อนการเปิดใช้งาน the external oscillators and the PLLs.
     0xx: no division
     100: หารด้วย 2
     101: division by 3
     110: division by 4
     111: division by 5

Bit 23 I2SSRC: I2S clock selection
     เซ็ตและเคลียร์โดย software. บิตนี้ยอมให้เลือก the I2S clock source ระหว่าง the PLLI2S clock และ the external clock. ขอ
     แนะนำอย่างยิ่งให้เปลี่ยนบิตนี้เฉพาะหลังจากรีเซ็ตและก่อนการเปิดใช้งาน the I2S module.
     0: PLLI2S clock ถูกใช้เป็น I2S clock source
     1: External clock ที่แมปบน the I2S_CKIN pin ถูกใช้เป็น I2S clock source

tha

Bits 22:21 MCO1: Microcontroller clock output 1
     เซ็ตและเคลียร์โดย software. Clock source selection อาจสร้าง glitches บน MCO1. ขอแนะนำอย่างยิ่งให้กำหนดค่าบิตเหล่านี้
     เฉพาะหลังจากรีเซ็ตก่อนการเปิดใช้งาน the external oscillators and the PLLs.
     00: HSI clock ถูกเลือก
     01: LSE oscillator selected
     10: HSE oscillator clock selected
     11: PLL clock selected

Bits 20:16 RTCPRE: HSE division factor for RTC clock
     เซ็ตและเคลียร์โดย software เพื่อหาร the HSE clock input clock เพื่อสร้าง a 1 MHz clock สำหรับ RTC.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องเพื่อให้แน่ใจว่า the clock ที่จ่ายให้กับ the RTC คือ 1 MHz. บิตเหล่านี้ต้อง
                      ถูกกำหนดค่าถ้าจำเป็นก่อนการเลือก the RTC clock source.
     00000: no clock
     00001: no clock
     00010: HSE/2
     00011: HSE/3
     00100: HSE/4
     ...
     11110: HSE/30
     11111: HSE/31

Bits 15:13 PPRE2: APB high-speed prescaler (APB2)
     เซ็ตและเคลียร์โดย software เพื่อควบคุม APB high-speed clock division factor.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องไม่ให้เกิน 108 MHz บนโดเมนนี้. The clocks ถูกหารด้วย the new
                      prescaler factor จาก 1 ถึง 16 AHB cycles หลังจาก PPRE2 write.
     0xx: AHB clock ไม่ถูกหาร
     100: AHB clock ถูกหารด้วย 2
     101: AHB clock divided by 4
     110: AHB clock divided by 8
     111: AHB clock divided by 16

Bits 12:10 PPRE1: APB Low-speed prescaler (APB1)
     เซ็ตและเคลียร์โดย software เพื่อควบคุม APB low-speed clock division factor.

     Caution: The software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องไม่ให้เกิน 54 MHz บนโดเมนนี้. The clocks ถูกหารด้วย the new
                      prescaler factor จาก 1 ถึง 16 AHB cycles หลังจาก PPRE1 write.Caution:
     0xx: AHB clock ไม่ถูกหาร
     100: AHB clock ถูกหารด้วย 2
     101: AHB clock divided by 4
     110: AHB clock divided by 8
     111: AHB clock divided by 16

Bits 9:8 Reserved, must be kept at reset value

tha

Bits 7:4 HPRE: AHB prescaler
     เซ็ตและเคลียร์โดย software เพื่อควบคุม AHB clock division factor.

     Caution: The clocks ถูกหารด้วย the new prescaler factor จาก 1 ถึง 16 AHB cycles หลังจาก HPRE write.

     Caution: The AHB clock frequency ต้องอย่างน้อย 25 MHz เมื่อ the Ethernet ถูกใช้.
     0xxx: system clock ไม่ถูกหาร
     1000: system clock ถูกหารด้วย 2
     1001: system clock divided by 4
     1010: system clock divided by 8
     1011: system clock divided by 16
     1100: system clock divided by 64
     1101: system clock divided by 128
     1110: system clock divided by 256
     1111: system clock divided by 512

Bits 3:2 SWS: System clock switch status
     เซ็ตและเคลียร์โดย hardware เพื่อแสดงให้เห็นว่า clock source ใดถูกใช้เป็น the system clock.
     00: HSI oscillator ถูกใช้เป็น the system clock
     01: HSE oscillator ถูกใช้เป็น the system clock
     10: PLL ถูกใช้เป็น the system clock
     11: ไม่เกี่ยวข้อง

Bits 1:0 SW: System clock switch
     เซ็ตและเคลียร์โดย software เพื่อเลือก the system clock source.
     เซ็ตโดย hardware เพื่อบังคับ the HSI selection เมื่อออกจาก the Stop หรือ Standby mode หรือในกรณีของความล้มเหลวของ
     the HSE oscillator ที่ใช้โดยตรงหรือโดยอ้อมเป็น the system clock.
     00: HSI oscillator ถูกเลือกเป็น system clock
     01: HSE oscillator ถูกเลือกเป็น system clock
     10: PLL ถูกเลือกเป็น system clock
     11: ไม่อนุญาติ