STM32F1 RCC

Started by tha, November 07, 2020, 08:35:59 AM

Previous topic - Next topic

tha

7 Low-, medium-, high- and XL-density reset and clock control (RCC)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

Section นี้ใช้กับ low-, medium-, high- and XL-density STM32F10xxx devices.
Connectivity line devicesจะกล่าวถึงในส่วนที่แยกต่างหาก (อ้างอิงถึง Connectivity line
devices: reset and clock control (RCC)).

7.1 Reset
มี 3 ชนิดของ reset, นิยามเป็น system reset, power reset และ backup domain reset.

7.1.1 System reset
A system reset เซ็ต registers ทั้งหมดไปเป็น reset values ของมันยกเว้น the reset flags ใน the clock controller CSR register และ the registers ใน the Backup domain (ดู Figure 4).
A system reset ถูกสร้างขึ้นเมื่อหนึ่งของ the following events เกิดขึ้น :
1. A low level บน the NRST pin (external reset)
2. Window watchdog การสิ้นสุดของเงื่อนใขการนับ (WWDG reset)
3. Independent watchdog การสิ้นสุดของเงื่อนใขการนับ (IWDG reset)
4. A software reset (SW reset) (ดู Software reset)
5. Low-power management reset (ดู Low-power management reset)
The reset source สามารถถูกระบุโดยการเช็ค the reset flags ใน the Control/Status register, RCC_CSR (ดู Section 7.3.10: Control/status register (RCC_CSR)).

tha

Software reset
The SYSRESETREQ bit ใน Cortex®-M3 Application Interrupt and Reset Control Register ต้องถูกเซ็ตเพื่อบังคับ(force) a software reset บน the device. อ้างอิงถึง the STM32F10xxx Cortex®-M3 programming manual (ดูเอกสารที่เกี่ยวข้อง) สำหรับรายละเอียดที่มากขึ้น.

Low-power management reset
มี 2 ทางที่จะสร้าง a low-power management reset:
1.    Reset สร้างขึ้นเมื่อเข้าสู่ Standby mode:
       reset ชนิดนี้ถูกเปิดการใช้งานโดยการรีเซ็ต nRST_STDBY bit ใน User Option Bytes. ในกรณีนี้, เมื่อไรก็ตาม a Standby
       mode entry sequence ถูกปฏิบัติสำเร็จลง, the device ถูก reset แทนการเข้าสู่ Standby mode.
2.    Reset เมื่อเข้าสู่ Stop mode:
       reset ชนิดนี้ถูกเปิดการใช้งานโดยการรีเซ็ต nRST_STOP bit ใน User Option Bytes. ในกรณีนี้, เมื่อไรก็ตาม a Stop mode
       entry sequence ถูกปฏิบัติสำเร็จลง, the device ถูก reset แทนการเข้าสู่ Stop mode.

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ the User Option Bytes, อ้างอิงถึง the STM32F10xxx Flash programming manual.

tha

7.1.2 Power reset
A power reset ถูกสร้างขึ้นเมื่อหนึ่งของ the following events เกิดขึ้น :
1. Power-on/power-down reset (POR/PDR reset)
2. เมื่อออกจาก Standby mode
A power reset เซ็ต registers ทั้งหมดไปเป็น reset values ของมันยกเว้น the Backup domain (ดู Figure 4)

sources เหล่านี้ทำงานบน the NRST pin และมันจะอยู่ในระดับต่ำเสมอในระหว่าง the delay phase. The RESET service routine vector ถูกคงที่ที่ address 0x0000_0004 ใน the memory map.

The system reset signal ที่ให้กับ the device จะ output ที่ the NRST pin. The pulse generator รับประกัน a minimum reset pulse ช่วงเวลาของ 20 μs สำหรับแต่ละ reset source (external หรือ internal reset). ในกรณีของ an external reset, the reset pulse ถูกสร้างขึ้นในขณะที่ the NRST pin ยืนยัน low.



tha

7.1.3 Backup domain reset
The backup domain มี 2 specific resets ที่เป็นผลกับเพียง the backup domain (ดู Figure 4).

A backup domain reset ถูกสร้างเมื่อหนึ่งของ the following events เกิดขึ้น :
1. Software reset, ทริกโดยการเซ็ต the BDRST bit ใน the Backup domain control register (RCC_BDCR).
2. VDD หรือ VBAT power on, ถ้าทั้งสอง supplies ถูก powered off มาก่อนหน้านี้.

tha

7.2 Clocks
Three different clock sources สามารถถูกใช้เพื่อขับ the system clock (SYSCLK):
•    HSI oscillator clock
•    HSE oscillator clock
•    PLL clock

The devices มี the following two secondary clock sources:
•    40 kHz low speed internal RC (LSI RC), ซึ่งขับ the independent watchdog และเป็นทางเลือกให้ the RTC ใช้สำหรับ
      Auto- wakeup จาก Stop/Standby mode.
•    32.768 kHz low speed external crystal (LSE crystal), ซึ่งเป็นทางเลือกใช้ขับ the real-time clock (RTCCLK)
      แต่ละ clock source สามารถถูก switched on หรือ off อย่างอิสระเมื่อมันไม่ได้ถูกใช้, เพื่อเพิ่มประสิทธิภาพ power consumption.



1. เมื่อ the HSI ถูกใช้เป็น a PLL clock input, the maximum system clock frequency ที่สามารถถูกทำให้สำเร็จได้คือ 64 MHz.

2. สำหรับรายละเอียดเติมเกี่ยวกับ the internal and external clock source characteristics อ้างอิงถึง the "Electrical
    characteristics" section ใน your device datasheet.

prescalers หลายตัวยอมให้กำหนดค่าของ the AHB frequency, the high speed APB(APB2) และ the low speed APB (APB1) domains. The maximum frequency ของ the AHB และ the APB2 domains คือ 72 MHz. The maximum allowed frequency ของ the APB1 domain คือ 36 MHz. The SDIO AHB interface ถูก clocked ด้วย a fixed frequency เท่ากับ HCLK/2

The RCC ให้(feeds) the Cortex® System Timer (SysTick) external clock ด้วย the AHB clock (HCLK) หารด้วย 8. The SysTick สามารถทำงานด้วย clock นี้หรือด้วย the Cortex® clock (HCLK) อย่างใดอย่างหนึ่ง, กำหนดค่าได้ใน the SysTick Control และ Status Register. The ADCs ถูก clocked โดย the clock ของ the High Speed domain (APB2) หารด้วย 2, 4, 6 หรือ 8.

The Flash memory programming interface clock (FLITFCLK) คือ the HSI clock เสมอ.

The timer clock frequencies ถูกคงที่โดยอัตโนมัติโดย. มันมีสองกรณี :
1. ถ้า the APB prescaler คือ 1, the timer clock frequencies ถูกเซ็ตเป็นความถี่เดียวกับของ the APB domain ซึ่ง the timers
    ถูกเชื่อมต่อ.
2. มิฉะนั้น, จะถูกตั้งค่าเป็นสองเท่า (× 2) ของความถี่ของ the APB domain ซึ่ง the timers ถูกเชื่อมต่อ.

FCLK ทำงานเป็น Cortex®-M3's free-running clock. สำหรับรายละเอียดที่มากขึ้นอ้างอิงถึง Arm® Cortex-M3 r1p1 Technical Reference Manual (TRM).

tha

7.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 และ startup stabilization time. The loading capacitance values ต้องถูกปรับให้สอดคล้องกับ the selected oscillator.



External source (HSE bypass)
ในโหมดนี้, an external clock source ต้องถูกจัดให้มี. มันสามารถมีความถี่ขึ้นไปถึง 25 MHz. คุณเลือกโหมดนี้โดยการเซ็ต 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 9.

External crystal/ceramic resonator (HSE crystal)
The 4 ถึง 16 MHz external oscillator มีข้อได้เปรียบในการสร้าง a very accurate rate บน the main clock

The associated hardware configuration ถูกแสดงใน Figure 9. อ้างอิงถึง 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

7.2.2 HSI clock
The HSI clock signal ถูกสร้างจาก an internal 8 MHz RC Oscillator และสามารถถูกใช้โดยตรงเป็น a system clock หรือหารด้วย 2 เพื่อถูกใช้เป็น 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

7.2.3 PLL
The internal PLL สามารถถูกใช้เพื่อคูณ the HSI RC output หรือ HSE crystal output clock frequency. อ้างอิงถึง Figure 8 และ Clock control register (RCC_CR). The PLL configuration (การเลือกของ HSI oscillator หารด้วย 2 หรือ HSE oscillator สำหรับ PLL input clock, และ multiplication factor) ต้องถูกทำก่อนการเปิดใช้งาน the PLL. เมื่อ the PLL เปิดการใช้งาน, parameters เหล่านี้ไม่สามารถถูกเปลี่ยน.

An interrupt สามารถถูกสร้างขึ้นเมื่อ the PLL พร้อมแล้ว ถ้าเปิดการใช้งานใน the Clock interrupt register (RCC_CIR).

ถ้า the USB interface ถูกใช้ใน the application, the PLL ต้องถูกโปรแกรมเป็น output 48 หรือ 72 MHz. นี้ถูกต้องการจัดให้มี a 48 MHz USBCLK.