STM32F1 PWR

Started by tha, October 29, 2020, 08:55:20 AM

Previous topic - Next topic

tha

5.3.3 Sleep mode
Entering Sleep mode
The Sleep mode ถูกเข้าสู่โดยการปฏิบัติคำสั่ง the WFI (Wait For Interrupt) หรือ WFE (Wait for Event) instructions. สองทางเลือกนี้มีให้ใช้เพื่อเลือกกลไกการเข้าสู่สลีปโหมด( the Sleep mode entry mechanism), ขึ้นอยู่กับ the SLEEPONEXIT bit ใน the Cortex?-M3 System Control register:
• Sleep-now(สลีปทันที): ถ้า the SLEEPONEXIT bit ถูกเคลียร์, the MCU เข้าสู่ Sleep mode ทันทีที่ WFI or WFE instruction
   ถูกปฏิบัติ.
• Sleep-on-exit(สลีปเมื่อออกจาก): ถ้า the SLEEPONEXIT bit ถูก set, the MCU เข้าสู่ Sleep mode ทันทีที่มันออกจากอินเต
   อรัพท์เซอร์วิสรูทีนลำดับความสำคัญต่ำสุด( the lowest priority ISR).

ใน the Sleep mode, I/O pins ทั้งหมดจะคงสถานะเดียวกันกับใน the Run mode.

อ้างอิงถึง Table 12 and Table 13 สำหรับรายละเอียดทำอย่างไรถึงจะเข้าสู่ Sleep mode.

Exiting Sleep mode
ถ้าคำสั่ง WFI  ถูกใช้เพื่อเข้าสู่ Sleep mode, peripheral interrupt ใดๆที่รับรู้ได้โดย the nested vectored interrupt controller (NVIC) สามารถปลูกให้ตื่น(wake up) the device จาก Sleep mode

ถ้าคำสั่ง WFE  ถูกใช้เพื่อเข้าสู่  Sleep mode, the MCU ออกจาก Sleep mode ทันทีที่ an event เกิดขึ้น. The wakeup event สามารถถูกทำให้เกิดขึ้นได้อย่างใดอย่างหนึ่งโดย :

• การเปิดการใช้งาน an interrupt ใน the peripheral control register แต่ไม่ใช่ใน the NVIC, และการเปิดการใช้งาน the
   SEVONPEND bit ใน the Cortex?-M3 System Control register. เมื่อ the MCU กลับคืนจาก WFE, the peripheral
   interrupt pending bit และ the peripheral NVIC IRQ channel pending bit (ใน the NVIC interrupt clear pending
   register) ต้องถูกเคลียร์.

• หรือการกำหนดค่า an external หรือ internal EXTI line ใน event mode. เมื่อ the CPU กลับคืนจาก WFE, มันไม่จำเป็นต้องเคลียร์
   the peripheral interrupt pending bit หรือ the NVIC IRQ channel pending bit เพราะ the pending bit ที่ตรงกันกับ the
   event line ไม่ได้ถูก set.

โหมดนี้ให้ the lowest wakeup time เพราะไม่มีเวลาสูญเสียใน interrupt entry/exit.

อ้างอิงถึง Table 12 and Table 13 สำหรับรายละเอียดทำอย่างไรถึงจะเข้าสู่ Sleep mode.

tha


tha

5.3.4 Stop mode
The Stop mode ถูกตั้งเป็นฐานบน the Cortex?-M3 deepsleep mode ร่วมกันกับ peripheral clock gating. The voltage regulator สามารถถูกกำหนดค่าใน normal หรือ low-power mode อย่างใดอย่างหนึ่ง. ใน Stop mode, clocks ทั้งหมดใน the 1.8 V domain ถูกหยุด, the PLL, the HSI และ the HSE RC oscillators ถูกปิดการใช้งาน. SRAM and register contents ถูกรักษาไว้.
ใน the Stop mode, I/O pins ทั้งหมดจะคงสถานะเดียวกันกับใน the Run mode.

Entering Stop mode
อ้างอิงถึง Table 14 สำหรับรายละเอียดทำอย่างไรถึงจะเข้าสู่ the Stop mode.
เพื่อลด power consumption เพิ่มขึ้นอีกใน Stop mode, the internal voltage regulator สามารถถูกใส่ลงใน low-power mode. ถูกกำหนดค่าโดย the LPDS bit ของ the Power control register (PWR_CR).

ถ้า Flash memory programming กำลังดำเนินการอยู่, the Stop mode entry ถูกล่าช้าออกไปจนกระทั่ง the memory access ถูกทำให้สำเร็จลง.

ถ้าการเข้าถึง the APB domain กำลังดำเนินการอยู่, The Stop mode entry ถูกล่าช้าออกไปจนกระทั่ง the APB access ถูกทำให้สำเร็จลง.

ใน Stop mode, คุณลักษณะดังต่อไปนี้สามารถถูกเลือกโดยการโปรแกรม individual control bits:
• Independent watchdog (IWDG): the IWDG ถูก started โดยการเขียนไปยัง Key register ของมันหรือโดย hardware
   option. เมื่อ started แล้วมันไม่สามารถถูก stopped ยกเว้นโดย a Reset ดู Section 19.3: IWDG functional description

• Real-time clock (RTC): นี้ถูกกำหนดค่าโดย the RTCEN bit ใน the Backup domain control register (RCC_BDCR)

• Internal RC oscillator (LSI RC): นี้ถูกกำหนดค่าโดย the LSION bit ใน the Control/status register (RCC_CSR).

• External 32.768 kHz oscillator (LSE OSC): นี้ถูกกำหนดค่าโดย the LSEON bit ใน the Backup domain control register (RCC_BDCR).

The ADC หรือ DAC สามารถกิน power ในระหว่าง the Stop mode ได้อีกด้วย, เว้นแต่มันถูกปิดการใช้งานก่อนการเข้าสู่มัน(Stop mode). เพื่อปิดการใช้งาน ADC และ DAC, the ADON bit ใน the ADC_CR2 register และ the ENx bit ใน the DAC_CR register ต้องถูกเขียนให้เป็น 0 ทั้งคู่.

Note: ถ้า the application ต้องการปิดการใช้งาน the external clock ก่อนการเข้าสู่ Stop mode, the HSEON bit ต้องถูกปิดการใช้งานเป็นอันดับแรกและ the system clock สวิทช์ไปยัง HSI. มิฉะนั้น, ถ้า the HSEON bit ยังคงเปิดการใช้งานอยู่และ the external clock (external oscillator) ถูกถอดออกเมื่อเข้าสู่ Stop mode, the clock security system (CSS) feature ต้องถูกเปิดการใช้งานเพื่อตรวจจับ external oscillator failure ใดๆและหลีกเลี่ยง a malfunction behavior เมื่อเข้าสู่ stop mode.

Exiting Stop mode
อ้างอิงถึง Table 14 สำหรับรายละเอียดทำอย่างไรถึงจะออกจาก the Stop mode.

เมื่อออกจาก Stop mode โดยการกำเนิด an interrupt หรือ a wakeup event, the HSI RC oscillator ถูกเลือกเป็น system clock.

เมื่อ the voltage regulator ทำงานใน low-power mode, an additional startup delay ถูกทำให้เกิดขึ้นเมื่อ waking up จาก Stop mode. โดยทำให้ the internal regulator ON ในระหว่าง Stop mode, the consumption จะสูงขึ้นแม้ว่า the startup time ถูกลดลง



WFI (Wait for Interrupt) หรือ WFE (Wait for Event) ขณะที่:
– เซ็ต SLEEPDEEP bit ใน Cortex®-M3 System Control register
– เคลียร์ PDDS bit ใน Power Control register (PWR_CR)
– เลือก the voltage regulator mode โดยการกำหนดค่า LPDS bit ใน PWR_CR

Note: เพื่อเข้าสู่ Stop mode, all EXTI Line pending bits (in Pending register (EXTI_PR)), all peripheral interrupt pending bits, and RTC Alarm flag ต้องถูก reset. มิฉะนั้น, the Stop mode entry procedure ถูกเพิกเฉยและ program execution ดำเนินต่อไป.

ถ้า WFI เคยถูกใช้สำหรับการเข้าสู่:
EXTI Line ใดๆกำหนดค่าใน Interrupt mode (the corresponding EXTI Interrupt vector ต้องถูก enabled ใน the NVIC). อ้างอิงถึง Section 10.1.2: Interrupt and exception vectors.

ถ้า WFE เคยถูกใช้สำหรับการเข้าสู่:
EXTI Line ใดๆกำหนดค่าใน event mode. อ้างอิงถึง Section 10.2.3: Wakeup event management

HSI RC wakeup time + regulator wakeup time จาก Low-power mode

ปล. ข้างล่างตารางนี้แปลในตารางนะครับ


tha

5.3.5 Standby mode
The Standby mode ช่วยให้บรรลุ the lowest power consumption. มันถูกตั้งเป็นรากฐานบน the Cortex®-M3 deepsleep mode, พร้อมด้วย the voltage regulator ปิดการใช้งาน. The 1.8 V domain ผลที่สุดก็คือถูก powered off. The PLL, the HSI oscillator และ the HSE oscillator ถูก switched off ด้วย. SRAM และ register contents จะสูญหายยกเว้นสำหรับ registers ใน the Backup domain และ Standby circuitry (ดู Figure 4).

Entering Standby mode
อ้างอิงถึง Table 15 สำหรับรายละเอียดทำอย่างไรถึงจะเข้าสู่ Standby mode.

ใน Standby mode, คุณลักษณะดังต่อไปนี้สามารถถูกเลือกโดยการโปรแกรม individual control bits:

• Independent watchdog (IWDG): the IWDG ถูก started โดยการเขียนไปยัง Key register ของมันหรือโดย hardware
   option. เมื่อ started แล้วมันไม่สามารถถูก stopped ยกเว้นโดย a Reset ดู Section 19.3: IWDG functional description

• Real-time clock (RTC): นี้ถูกกำหนดค่าโดย the RTCEN bit ใน the Backup domain control register (RCC_BDCR)

• Internal RC oscillator (LSI RC): นี้ถูกกำหนดค่าโดย the LSION bit ใน the Control/status register (RCC_CSR).

• External 32.768 kHz oscillator (LSE OSC): นี้ถูกกำหนดค่าโดย the LSEON bit ใน the Backup domain control register
   (RCC_BDCR).

Exiting Standby mode
The microcontroller ออกจาก the Standby mode เมื่อ an external reset (NRST pin), an IWDG reset, a rising edge บน the WKUP pin หรือ the rising edge ของ an RTC alarm เกิดขึ้น (ดู Figure 179: RTC simplified block diagram). registers ทั้งหมดถูก reset หลังจาก wakeup จาก Standby ยกเว้นสำหรับ Power control/status register (PWR_CSR).

หลังจาก waking up จาก Standby mode, program execution restarts(เริ่มใหม่)ในทางเดียวกันกับหลังจาก a Reset (boot pins sampling(สุ่ม), vector reset ถูก fetched, ฯลฯ.). The SBF status flag ใน the Power control/status register (PWR_CSR) แสดงว่า the MCU เคยอยู่ใน Standby mode.

อ้างอิงถึง Table 15 สำหรับรายละเอียดทำอย่างไรถึงจะออกจาก Standby mode.


tha

I/O states(สถานะ) ใน Standby mode
ใน Standby mode, I/O pins ทั้งหมดเป็น high impedance ยกเว้น:
• Reset pad (ยังคงมีให้ใช้งาน)
• TAMPER pin ถ้ากำหนดค่าสำหรับ tamper หรือ calibration out
• WKUP pin, ถ้าเปิดการใช้งาน

Debug mode
โดยค่าเริ่มต้น, the debug connection จะสูญหายถ้า the application ใส่ the MCU ใน Stop หรือ Standby mode ในขณะที่ the debug features ถูกใช้. นี้เนื่องจากความจริงแล้ว the Cortex®-M3 core ไม่มีการ clocked อีกต่อไป.

อย่างไรก็ตาม, โดยการเซ็ต some configuration bits ใน the DBGMCU_CR register, the software สามารถถูก debugged แม้ว่าเมื่อใช้ the low-power modes อย่างกว้างขวาง(ยาวนาน)ก็ตาม. สำหรับรายละเอียดที่มากขึ้น, อ้างอิงถึง Section 31.16.1: Debug support for low-power modes.

tha

5.3.6 Auto-wakeup (AWU) from low-power mode
The RTC สามารถถูกใช้เพื่อปลุก the MCU จาก low-power mode โดยปราศจากการขึ้นอยู่กับ an external interrupt (Auto-wakeup mode). The RTC จัดให้มี a programmable time base สำหรับ waking up จาก Stop หรือ Standby mode ที่ช่วงเวลาปกติ. สำหรับจุดมุ่งหมายนี้, สองของ the three alternative RTC clock sources สามารถถูกเลือกโดยการโปรแกรม the RTCSEL[1:0] bits ใน the Backup domain control register (RCC_BDCR):

• Low-power 32.768 kHz external crystal oscillator (LSE OSC).
   clock source นี้จัดให้มี a precise time base ด้วย very low-power consumption (น้อยกว่า 1μA การบริโภคที่เพิ่มขึ้นในสภาวะ
   ปกติ)

• Low-power internal RC Oscillator (LSI RC)
   clock source นี้มีข้อได้เปรียบในการประหยัดราคาของ the 32.768 kHz crystal. internal RC Oscillator นี้ถูกออกแบบมาเพื่อเพิ่ม
   minimum power consumption.

เพื่อ wakeup จาก Stop mode ด้วย an RTC alarm event, มันมีความจำเป็นต้อง :
• กำหนดค่า the EXTI Line 17 ให้ sensitive ต่อ rising edge
• กำหนดค่า the RTC เพื่อสร้าง the RTC alarm
เพื่อ wakeup จาก Standby mode, ไม่มีความจำเป็นต้องกำหนดค่า the EXTI Line 17.

tha

5.4 Power control registers
The peripheral registers สามารถถูกเข้าถึงโดย half-words (16-bit) หรือ words (32-bit).



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

Bit 8 DBP: Disable backup domain write protection.
ใน reset state, the RTC and backup registers ถูกป้องกันต้าน parasitic write access.
บิตนี้ต้องถูกเซ็ตเพื่อเปิดการใช้งาน write access ไปยัง registers เหล่านี้.
     0: การเข้าถึง RTC and Backup registers ปิดการใช้งานอยู่
     1: การเข้าถึง RTC and Backup registers เปิดการใช้งานอยู่
Note: ถ้า the HSE หารโดย 128 ถูกใช้เป็น the RTC clock, บิตนี้ต้องยังคงเซ็ตเป็น 1.

Bits 7:5 PLS[2:0]: PVD level selection.
บิตเหล่านี้ถูกเขียนโดย software เพื่อเลือก the voltage threshold(ขอบเขต) ตรวจจับโดย the Power Voltage Detector
     000: 2.2V
     001: 2.3V
     010: 2.4V
     011: 2.5V
     100: 2.6V
     101: 2.7V
     110: 2.8V
     111: 2.9V
Note: อ้างอิงถึง the electrical characteristics ของ the datasheet สำหรับรายละเอียดที่มากขึ้น.

Bit 4 PVDE: Power voltage detector enable.
บิตนี้ถูกเซ็ตและเคลียร์โดย software.
     0: PVD ปิดการใช้งานอยู่
     1: PVD เปิดการใช้งานอยู่

Bit 3 CSBF: Clear standby flag.
บิตนี้ถูกอ่านได้เป็น 0 เสมอ.
     0: ไม่เป็นผล
     1: เคลียร์ the SBF Standby Flag (write).

Bit 2 CWUF: Clear wakeup flag.
บิตนี้ถูกอ่านได้เป็น 0 เสมอ.
     0: ไม่เป็นผล
     1: เคลียร์ the WUF Wakeup Flag หลังจาก 2 System clock cycles. (write)

Bit 1 PDDS: Power down deepsleep.
บิตนี้ถูกเซ็ตและเคลียร์โดย software. มันทำงานร่วมกันกับ the LPDS bit.
     0: เข้าสู่ Stop mode เมื่อ the CPU เข้าสู่ Deepsleep. The regulator status ขึ้นอยู่กับ the LPDS bit.
     1: เข้าสู่ Standby mode เมื่อ the CPU เข้าสู่ Deepsleep.

Bit 0 LPDS: Low-power deepsleep.
บิตนี้ถูกเซ็ตและเคลียร์โดย software. มันทำงานร่วมกันกับ the PDDS bit.
     0: Voltage regulator on ในระหว่าง Stop mode
     1: Voltage regulator ใน low-power mode ในระหว่าง Stop mode

tha



Bits 31:9 Reserved, must be kept at reset value.
Bit 8 EWUP: Enable WKUP pin
บิตนี้เซ็ตและเคลียร์โดย software.
     0: WKUP pin ถูกใช้สำหรับ general purpose I/O. An event บน the WKUP pin ไม่ wakeup the device จาก Standby
         mode.
     1: WKUP pin ถูกใช้สำหรับ wakeup จาก Standby mode และถูกบังคับใน input pull down configuration (rising edge บน
         WKUP pin ปลุก(wakes-up) the system จาก Standby mode).
Note: บิตนี้ถูก reset โดย a system Reset.

Bits 7:3 Reserved, must be kept at reset value.
Bit 2 PVDO: PVD output
บิตนี้เซ็ตและเคลียร์โดย software. มันจะใช้ได้เพียงถ้า PVD ถูกเปิดการใช้งานโดย the PVDE bit.
     0: VDD/VDDA สูงกว่า the PVD threshold(ขอบเขต) ที่เลือกด้วย the PLS[2:0] bits.
     1: VDD/VDDA ต่ำกว่า the PVD threshold(ขอบเขต) ที่เลือกด้วย the PLS[2:0] bits.
Note: The PVD ถูกหยุดโดย Standby mode. สำหรับเหตุผลนี้, บิตนี้เท่ากับ 0 หลังจาก Standby หรือ reset จนกระทั่ง the PVDE bit ถูกเซ็ต.

Bit 1 SBF: Standby flag
บิตนี้ถูกเซ็ตโดย hardware และเคลียร์ได้เพียงโดย a POR/PDR (power on reset/power down reset) หรือโดยการเซ็ต the CSBF bit ใน the Power control register (PWR_CR)
     0: Device ไม่ได้อยู่ใน Standby mode มา   (ตั้งแต่อดีตจนถึงปัจจุบัน)
     1: Device อยูใน Standby mode มา    (ตั้งแต่อดีตจนถึงปัจจุบัน)

Bit 0 WUF: Wakeup flag
บิตนี้ถูกเซ็ตโดย hardware และเคลียร์โดย hardware, โดย a system reset หรือโดยการเซ็ต the CWUF bit ใน the Power control register (PWR_CR)
     0: ไม่มี wakeup event เกิดขึ้น
     1: A wakeup event เคยถูกได้รับจาก the WKUP pin หรือจาก the RTC alarm
Note: An additional(เพิ่มเติม) wakeup event ถูกตรวจจับได้ถ้า the WKUP pin ถูกเปิดการใช้งาน (โดยการเซ็ต the EWUP bit) เมื่อ the WKUP pin level อยู่สูงอยู่แล้ว.