STM32F1 RCC

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

Previous topic - Next topic

tha



         1 or 2 wait states inserted only if the access occurs during clock source switch.
       (1 or 2 wait states ถูกแทรกเพียงถ้าการเข้าถึงเกิดขึ้นในระหว่าง clock source switch เท่านั้น.)

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

Bits 26:24 MCO: Microcontroller clock output
เซ็ตและเคลียร์โดย software.
     0xx: No clock
     100: System clock (SYSCLK) ถูกเลือก
     101: HSI clock selected
     110: HSE clock selected
     111: PLL clock divided by 2 selected
Note: clock output นี้อาจมีบาง truncated cycles ที่ startup หรือในระหว่าง MCO clock source switching.
เมื่อ the System Clock ถูกเลือกเป็น output ไปยัง the MCO pin, ต้องทำให้แน่ใจว่า clock นี้ไม่เกิน 50 MHz (the maximum IO speed).

Bit 22 USBPRE: USB prescaler
เซ็ตและเคลียร์โดย software เพื่อสร้าง 48 MHz USB clock. บิตนี้ต้องเป็นผลก่อนการเปิดการใช้งาน the USB clock ใน the RCC_APB1ENR register. บิตนี้ไม่สามารถถูก reset ถ้า the USB clock ถูก enabled.
     0: PLL clock ถูกหารด้วย 1.5
     1: PLL clock ไม่ถูกหาร

Bits 21:18 PLLMUL: PLL multiplication factor
บิตเหล่านี้ถูกเขียนโดย soltware เพื่อกำหนด the PLL multiplication factor. บิตเหล่านี้สามารถถูกเขียนได้เพียงเมื่อ PLL ถูก disabled เท่านั้น.
ข้อควรระวัง: The PLL output frequency ต้องไม่เกิน 72 MHz.
     0000: PLL input clock x 2
     0001: PLL input clock x 3
     0010: PLL input clock x 4
     0011: PLL input clock x 5
     0100: PLL input clock x 6
     0101: PLL input clock x 7
     0110: PLL input clock x 8
     0111: PLL input clock x 9
     1000: PLL input clock x 10
     1001: PLL input clock x 11
     1010: PLL input clock x 12
     1011: PLL input clock x 13
     1100: PLL input clock x 14
     1101: PLL input clock x 15
     1110: PLL input clock x 16
     1111: PLL input clock x 16

Bit 17 PLLXTPRE: HSE divider for PLL entry
เซ็ตและเคลียร์โดย software เพื่อหาร HSE ก่อนการเข้าสู่ PLL . บิตนี้สามารถถูกเขียนได้เพียงเมื่อ PLL ถูก disabled เท่านั้น.
     0: HSE clock ไม่ถูกหาร
     1: HSE clock ถูกหารด้วย 2

Bit 16 PLLSRC: PLL entry clock source
เซ็ตและเคลียร์โดย software เพื่อเลือก PLL clock source . บิตนี้สามารถถูกเขียนได้เพียงเมื่อ PLL ถูก disabled เท่านั้น.
     0: HSI oscillator clock / 2 ถูกเลือกเป็น PLL input clock
     1: HSE oscillator clock ถูกเลือกเป็น PLL input clock

Bits 15:14 ADCPRE: ADC prescaler
เซ็ตและเคลียร์โดย software เพื่อเลือก the frequency ของ the clock ไปยัง the ADCs.
     00: PCLK2 ถูกหารด้วย 2
     01: PCLK2 divided by 4
     10: PCLK2 divided by 6
     11: PCLK2 divided by 8

Bits 13:11 PPRE2: APB high-speed prescaler (APB2)
เซ็ตและเคลียร์โดย software เพื่อควบคุม the division factor ของ the APB high-speed clock (PCLK2).
     0xx: HCLK ไม่ถูกหาร
     100: HCLK ถูกหารด้วย 2
     101: HCLK divided by 4
     110: HCLK divided by 8
     111: HCLK divided by 16

Bits 10:8 PPRE1: APB low-speed prescaler (APB1)
เซ็ตและเคลียร์โดย software เพื่อควบคุม the division factor ของ the APB low-speed clock (PCLK1).
คำเตือน: the software ต้องเซ็ตบิตเหล่านี้อย่างถูกต้องไม่ให้เกิน 36 MHz บน domain นี้.
     0xx: HCLK ไม่ถูกหาร
     100: HCLK ถูกหารด้วย 2
     101: HCLK divided by 4
     110: HCLK divided by 8
     111: HCLK divided by 16

Bits 7:4 HPRE: AHB prescaler
เซ็ตและเคลียร์โดย software เพื่อควบคุม the division factor ของ the AHB clock.
     0xxx: SYSCLK ไม่ถูกหาร
     1000: SYSCLK ถูกหารด้วย 2
     1001: SYSCLK divided by 4
     1010: SYSCLK divided by 8
     1011: SYSCLK divided by 16
     1100: SYSCLK divided by 64
     1101: SYSCLK divided by 128
     1110: SYSCLK divided by 256
     1111: SYSCLK divided by 512
Note: The prefetch buffer ต้องถูกเก็บไว้เมื่อใช้ a prescaler แตกต่างไปจาก 1 บน the AHB clock. อ้างอิงถึง Reading the Flash memory section สำหรับรายละเอียดที่มากขึ้น.

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

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

tha



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

Bit 23 CSSC: Clock security system interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the CSSF flag.
     0: ไม่มีผลอะไร
     1: เคลียร์ CSSF flag

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

Bit 20 PLLRDYC: PLL ready interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the PLLRDYF flag.
     0: ไม่มีผลอะไร
     1: PLLRDYF ถูกเคลียร์

Bit 19 HSERDYC: HSE ready interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the HSERDYF flag.
     0: ไม่มีผลอะไร
     1: HSERDYF ถูกเคลียร์

Bit 18 HSIRDYC: HSI ready interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the HSIRDYF flag.
     0: ไม่มีผลอะไร
     1: HSIRDYF ถูกเคลียร์

Bit 17 LSERDYC: LSE ready interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the LSERDYF flag.
     0: ไม่มีผลอะไร
     1: LSERDYF ถูกเคลียร์

Bit 16 LSIRDYC: LSI ready interrupt clear
บิตนี้ถูกเซ็ตโดย software เพื่อเคลียร์ the LSIRDYF flag.
     0: ไม่มีผลอะไร
     1: LSIRDYF ถูกเคลียร์

Bits 15:13 Reserved, must be kept at reset value.

Bit 12 PLLRDYIE: PLL ready interrupt enable
บิตนี้ถูกเซ็ตและเคลียร์โดย software เพื่อ enable/disable interrupt ที่เป็นเหตุโดย PLL lock.
     0: PLL lock interrupt ถูกปิดการใช้งาน
     1: PLL lock interrupt ถูกเปิดการใช้งาน

Bit 11 HSERDYIE: HSE ready interrupt enable
Set and cleared by software to enable/disable interrupt caused by the external 4-16 MHz oscillator stabilization.
     0: HSE ready interrupt disabled
     1: HSE ready interrupt enabled

Bit 10 HSIRDYIE: HSI ready interrupt enable
Set and cleared by software to enable/disable interrupt caused by the internal 8 MHz RC oscillator stabilization.
     0: HSI ready interrupt disabled
     1: HSI ready interrupt enabled

Bit 9 LSERDYIE: LSE ready interrupt enable
Set and cleared by software to enable/disable interrupt caused by the external 32 kHz oscillator stabilization.
     0: LSE ready interrupt disabled
     1: LSE ready interrupt enabled

Bit 8 LSIRDYIE: LSI ready interrupt enable
Set and cleared by software to enable/disable interrupt caused by internal RC 40 kHz
oscillator stabilization.
     0: LSI ready interrupt disabled
     1: LSI ready interrupt enabled

Bit 7 CSSF: Clock security system interrupt flag
เซ็ตโดย hardware เมื่อ a failure ถูกตรวจจับได้ใน the external 4-16 MHz oscillator.
ถูกเคลียร์โดย software โดยการเซ็ต the CSSC bit.
     0: ไม่มี clock security interrupt เหตุโดย HSE clock failure
     1: Clock security interrupt เหตุโดย HSE clock failure

Bits 6:5 Reserved, must be kept at reset value
.
Bit 4 PLLRDYF: PLL ready interrupt flag
เซ็ตโดย hardware เมื่อ the PLL locks และ PLLRDYDIE ถูก set.
ถูกเคลียร์โดย software โดยการเซ็ต the PLLRDYC bit.
     0: ไม่มี clock ready interrupt เหตุโดย PLL lock
     1: Clock ready interrupt เหตุโดย PLL lock

Bit3 HSERDYF: HSE ready interrupt flag
เซ็ตโดย hardware เมื่อ External High Speed clock มีความเสถียรและ HSERDYDIE ถูก set.
ถูกเคลียร์โดย software โดยการเซ็ต the HSERDYC bit.
     0: No clock ready interrupt caused by the external 4-16 MHz oscillator
     1: Clock ready interrupt caused by the external 4-16 MHz oscillator

Bit 2 HSIRDYF: HSI ready interrupt flag
Set by hardware when the Internal High Speed clock becomes stable and HSIRDYDIE is set.
Cleared by software setting the HSIRDYC bit.
     0: No clock ready interrupt caused by the internal 8 MHz RC oscillator
     1: Clock ready interrupt caused by the internal 8 MHz RC oscillator

Bit 1 LSERDYF: LSE ready interrupt flag
Set by hardware when the External Low Speed clock becomes stable and LSERDYDIE is set.
Cleared by software setting the LSERDYC bit.
     0: No clock ready interrupt caused by the external 32 kHz oscillator
     1: Clock ready interrupt caused by the external 32 kHz oscillator

Bit 0 LSIRDYF: LSI ready interrupt flag
Set by hardware when the internal low speed clock becomes stable and LSIRDYDIE is set.
Cleared by software setting the LSIRDYC bit.
     0: No clock ready interrupt caused by the internal RC 40 kHz oscillator
     1: Clock ready interrupt caused by the internal RC 40 kHz oscillator

tha



tha


tha

7.3.6 AHB peripheral clock enable register (RCC_AHBENR)
Address offset: 0x14
Reset value: 0x0000 0014
Access: no wait state, word, half-word and byte access
Note: เมื่อ the peripheral clock ไม่ทำงาน, the peripheral register values อาจไม่ถูกอ่านได้โดย software และ the returned value เป็น 0x0 เสมอ.



Bits 31:11 Reserved, must be kept at reset value.
Bit 10 SDIOEN: SDIO clock enable
เซ็ตและเคลียร์โดย software.
     0: SDIO clock ถูกปิดการใช้งาน
     1: SDIO clock ถูกเปิดการใช้งาน

Bits 9 Reserved, always read as 0.

Bit 8 FSMCEN: FSMC clock enable
Set and cleared by software.
     0: FSMC clock disabled
     1: FSMC clock enabled

Bit 7 Reserved, always read as 0.

Bit 6 CRCEN: CRC clock enable
Set and cleared by software.
     0: CRC clock disabled
     1: CRC clock enabled

Bit 5 Reserved, must be kept at reset value.

Bit 4 FLITFEN: FLITF clock enable
เซ็ตและเคลียร์โดย software เพื่อ disable/enable FLITF clock ในระหว่าง Sleep mode.
     0: FLITF clock ถูกปิดการใช้งานในระหว่าง Sleep mode
     1: FLITF clock ถูกเปิดการใช้งานในระหว่าง Sleep mode

Bit 3 Reserved, must be kept at reset value.

Bit 2 SRAMEN: SRAM interface clock enable
เซ็ตและเคลียร์โดย software เพื่อ disable/enable SRAM interface clock ในระหว่าง Sleep mode.
     0: SRAM interface clock ถูกปิดการใช้งานในระหว่าง Sleep mode.
     1: SRAM interface clock ถูกเปิดการใช้งานในระหว่าง Sleep mode

Bit 1 DMA2EN: DMA2 clock enable
Set and cleared by software.
     0: DMA2 clock disabled
     1: DMA2 clock enabled

Bit 0 DMA1EN: DMA1 clock enable
Set and cleared by software.
     0: DMA1 clock disabled
     1: DMA1 clock enabled

ปล. ตามกันทันมั๊ย ช้าหรือเร็วไปก็บอกกันมา เข้าหน้าหนาวแล้ว อากาศกำลังเย็นสบายก็ไปได้เรื่อยๆครับ

tha

7.3.7 APB2 peripheral clock enable register (RCC_APB2ENR)
Address: 0x18
Reset value: 0x0000 0000
Access: word, half-word and byte access

ไม่มี wait states, ยกเว้นถ้าการเข้าถึงเกิดขึ้นขณะที่การเข้าถึง a peripheral ใน the APB2 domain กำลังดำเนินการอยู่. ในกรณีนี้, wait states จะถูกแทรกจนกระทั่งการเข้าถึง APB2 peripheral ถูกทำให้สำเร็จลง.

Note: เมื่อ the peripheral clock ไม่ทำงาน, the peripheral register values อาจไม่ถูกอ่านได้โดย software และ the returned value เป็น 0x0 เสมอ.






tha

7.3.8 APB1 peripheral clock enable register (RCC_APB1ENR)
Address: 0x1C
Reset value: 0x0000 0000
Access: word, half-word and byte access

ไม่มี wait states, ยกเว้นถ้าการเข้าถึงเกิดขึ้นขณะที่การเข้าถึง a peripheral ใน the APB1 domain กำลังดำเนินการอยู่. ในกรณีนี้, wait states จะถูกแทรกจนกระทั่งการเข้าถึง APB1 peripheral ถูกทำให้สำเร็จลง.

Note: เมื่อ the peripheral clock ไม่ทำงาน, the peripheral register values อาจไม่ถูกอ่านได้โดย software และ the returned value เป็น 0x0 เสมอ.






tha

7.3.9 Backup domain control register (RCC_BDCR)
Address offset: 0x20
Reset value: 0x0000 0000, reset by Backup domain Reset.
Access: 0 ≤ wait state ≤ 3, word, half-word and byte access
Wait states ถูกแทรกในกรณีของการเข้าถึงอย่างต่อเนื่องไปยัง register นี้

Note: The LSEON, LSEBYP, RTCSEL and RTCEN bits ของ the Backup domain control register (RCC_BDCR) อยู่ใน the Backup domain. ผลที่ตามมา, หลังจาก Reset, บิตเหล่านี้ถูกป้องกันการเขียนและ the DBP bit ใน the Power control register (PWR_CR) ต้องถูกเซ็ตก่อนบิตเหล่านี้สามารถถูกแก้ไข. อ้างอิงถึง Section 5: Power control (PWR) สำหรับข้อมูลเพิ่มเติม. บิตเหล่านี้ถูกรีเซ็ตได้เพียงหลังจาก a Backup domain Reset (ดู Section 7.1.3: Backup domain reset). internal or external Reset ใดๆจะไม่มีผลใดๆบนบิตเหล่านี้



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

Bit 16 BDRST: Backup domain software reset
เซ็ตและเคลียร์โดย software.
     0: Reset ไม่ได้ทำงาน
     1: รีเซ็ต the entire Backup domain

Bit 15 RTCEN: RTC clock enable
เซ็ตและเคลียร์โดย software
     0: RTC clock ถูกปิดการใช้งาน
     1: RTC clock ถูกเปิดการใช้งาน

Bits 14:10 Reserved, must be kept at reset value.

Bits 9:8 RTCSEL[1:0]: RTC clock source selection
เซ็ตโดย software เพื่อเลือก the clock source สำหรับ the RTC. เมื่อOnce the RTC clock source ถูกเลือกแล้วจะไม่สามารถเปลี่ยนแปลงได้อีกต่อไปเว้นแต่ the Backup domain ถูกรีเซ็ต. The BDRST bit สามารถถูกใช้เพื่อรีเซ็ตมัน.
     00: No clock
     01: LSE oscillator clock ใช้เป็น RTC clock
     10: LSI oscillator clock used as RTC clock
     11: HSE oscillator clock หารด้วย 128 used as RTC clock

Bits 7:3 Reserved, must be kept at reset value.

Bit 2 LSEBYP: External low-speed oscillator bypass
เซ็ตและเคลียร์โดย software เพื่อข้ามผ่าน oscillator ใน debug mode. บิตนี้สามารถถูกเขียนได้เพียงเมื่อ the external 32 kHz oscillator ถูกปิดการใช้งาน.
     0: LSE oscillator ไม่ถูกข้ามผ่าน
     1: LSE oscillator ถูกข้ามผ่าน

Bit 1 LSERDY: External low-speed oscillator ready
เซ็ตและเคลียร์โดย hardware เพื่อแสดงเมื่อ the external 32 kHz oscillator มีความเสถียร. หลังจาก the LSEON bit ถูกเคลียร์, LSERDY ลงไป low หลังจาก 6 external low-speed oscillator clock cycles.
     0: External 32 kHz oscillator not ready
     1: External 32 kHz oscillator ready

Bit 0 LSEON: External low-speed oscillator enable
Set and cleared by software.
     0: External 32 kHz oscillator OFF
     1: External 32 kHz oscillator ON