STM32F1 Backup registers (BKP)

Started by tha, November 05, 2020, 08:21:21 AM

Previous topic - Next topic

tha

6 Backup registers (BKP)
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.
ส่วนนี้ใช้กับ the whole STM32F101xx family, เว้นแต่จะระบุไว้เป็นอย่างอื่น.

6.1 BKP introduction
The backup registers เป็น 42 16-bit registers สำหรับเก็บ 84 bytes ของ user application data.

มันถูกทำให้เป็นผลใน the backup domain ที่ยังคง powered on โดย VBAT เมื่อ the VDD power ถูก switched off. มันไม่ถูก reset เมื่อ the device wakes up จาก Standby mode หรือโดย a system reset หรือ power reset.

นอกจากนี้, the BKP control registers ถูกใช้เพื่อจัดการ the Tamper detection feature และ RTC calibration.

หลังจาก reset, การเข้าถึง the Backup registers และ RTC ถูกปิดการใช้งานและ the Backup domain (BKP) ถูกป้องกันต้าน possible parasitic write access. เพื่อเปิดการใช้งานการเข้าถึง the Backup registers และ the RTC, ดำเนินการดังนี้ :
• เปิดการใช้งาน the power และ backup interface clocks โดยการเซ็ต the PWREN และ BKPEN bits ใน the RCC_APB1ENR
   register
• เซ็ต the DBP bit the Power Control Register (PWR_CR) เพื่อเปิดการใช้งานการเข้าถึง the Backup registers and RTC.

tha

6.2 BKP main features
• 20-byte data registers (ใน medium-density และ low-density devices) หรือ 84-byte data registers (ใน high-density, XL-density และ connectivity line devices)
• Status/control register สำหรับการจัดการ tamper detection พร้อมด้วย interrupt capability
• Calibration register สำหรับการเก็บ the RTC calibration value
• ความสามารถที่จะเอ๊าท์พุท the RTC Calibration Clock, RTC Alarm pulse หรือ Second pulse on TAMPER pin PC13 (เมื่อพินนี้ไม่ได้ถูกใช้สำหรับ tamper detection)

tha

6.3 BKP functional description
6.3.1 Tamper detection
The TAMPER pin ทำให้เกิด a Tamper detection event เมื่อพินนี้เปลี่ยนจาก 0 เป็น 1 หรือจาก 1 เป็น 0 ขึ้นอยู่กับ the TPAL bit ใน the Backup control register (BKP_CR). A tamper detection event รีเซ็ต data backup registers ทั้งหมด

อย่างไรก็ตามเพื่อหลีกเลี่ยงการสูญหาย Tamper events, the signal ที่ใช้สำหรับ edge detection ถูก logically ANDed ด้วย the Tamper enable เพื่อที่จะตรวจจับ a Tamper event ในกรณีที่มันเกิดขึ้นก่อน the TAMPER pin ถูก enabled.
• เมื่อ TPAL=0: ถ้า the TAMPER pin เป็น high แล้วก่อนที่มันถูก enabled (โดยการเซ็ต TPE bit), an extra Tamper event ถูก
   ตรวจจับทันทีที่ the TAMPER pin ถูก enabled (ในขณะที่ไม่เคยมี rising edge บน the TAMPER pin หลังจาก TPE ถูกเซ็ตแล้ว)
• เมื่อ TPAL=1: ถ้า the TAMPER pin เป็น low แล้วก่อนที่มันถูก enabled (โดยการเซ็ต the TPE bit), an extra Tamper event
   ถูกตรวจจับทันทีที่ the TAMPER pin ถูก enabled (ในขณะที่ไม่เคยมี falling edge บน the TAMPER pin หลังจาก TPE ถูกเซ็ตแล้ว)

โดยการเซ็ต the TPIE bit ใน the BKP_CSR register, an interrupt ถูกสร้างขึ้นเมื่อ a Tamper detection event เกิดขึ้น.

หลังจาก a Tamper event ถูกตรวจจับและเคลียร์แล้ว, the TAMPER pin ควรถูก disabled และจากนั้น re-enabled ด้วย TPE ก่อนเขียนไปยัง the backup data registers (BKP_DRx) อีกครั้ง. นี้ป้องกัน software จากการเขียนไปยัง the backup data registers (BKP_DRx), ในขณะที่ the TAMPER pin value ยังคงแสดง a Tamper detection. สิ่งนี้เทียบเท่ากับ a level detection บน the
TAMPER pin.

Note: Tamper detection ยังคง active เมื่อ VDD power ถูก switched off. เพื่อหลีกเลี่ยงความไม่ต้องการการรีเซ็ตของ the data backup registers, the TAMPER pin ควรถูกต่อภายนอกกับ the correct level.


tha

6.3.2 RTC calibration
เพื่อวัตถุประสงค์ในการวัด, the RTC clock ด้วย a frequency หารโดย 64 สามารถถูก output ไปบน the TAMPER pin. นี้ถูกเปิดการใช้งานโดยการเซ็ต the CCO bit ใน the RTC clock calibration register (BKP_RTCCR)

The clock สามารถถูกทำให้ช้าลงโดยขึ้นถึง 121 ppm โดยการกำหนดค่า CAL[6:0] bits

สำหรับรายละเอียดที่มากขึ้นเกี่ยวกับ RTC calibration และทำอย่างไรเพื่อใช้มันเพื่อปรับปรุงความแม่นยำในการบอกเวลา, อ้างอิงถึง AN2604 "STM32F101xx and STM32F103xx RTC calibration

tha

6.4 BKP registers
อ้างอิงถึง Section 2.2 on page 45สำหรับรายการของตัวย่อใช้ใน register descriptions.
The peripheral registers สามารถถูกเข้าถึงโดย half-words (16-bit) หรือ words (32-bit).



Bits 15:0 D[15:0] Backup data
      บิตเหล่านี้สามารถถูกเขียนด้วย user data.
    Note: The BKP_DRx registers ไม่ถูก reset โดย a System reset หรือ Power reset หรือเมื่อ the device
                 ปลุก(wakes up)จาก Standby mode.
                 พวกมันถูก reset โดย a Backup Domain reset หรือโดย a TAMPER pin event (ถ้า the TAMPER pin
                 function ถูกทำให้ทำงาน).

tha



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

Bit 9 ASOS: Alarm or second output selection
เมื่อ the ASOE bit ถูก set, the ASOS bit สามารถถูกใช้เลือกว่า the signal output on the TAMPER pin เป็น the RTC Second pulse signal หรือ the Alarm pulse signal:
     0: RTC Alarm pulse output เลือกอยู่
     1: RTC Second pulse output เลือกอยู่
Note: บิตนี้ถูก reset ได้เพียงโดย a Backup domain reset.

Bit 8 ASOE: Alarm or second output enable
     การเซ็ตบิตนี้จะ outputs อย่างใดอย่างหนึ่ง the RTC Alarm pulse signal หรือ the Second pulse signal ไปบน the TAMPER
     pin ขึ้นอยู่กับ the ASOS bit.
     The output pulse duration คือ one RTC clock period. The TAMPER pin ต้องไม่ถูก enabled ในขณะที่ the ASOE bit ถูก
     set.
Note: บิตนี้ถูก reset ได้เพียงโดย a Backup domain reset.

Bit 7 CCO: Calibration clock output
     0: ไม่มีผลอะไร
     1: การเซ็ตบิตนี้จะ outputs the RTC clock ด้วย a frequency ที่หารโดย 64 บน the TAMPER pin. The TAMPER pin ต้องไม่
         ถูก enabled ในขณะที่ the CCO bit ถูก set เพื่อหลีกเลี่ยง unwanted Tamper detection.
Note: บิตนี้ถูก reset เมื่อ the VDD supply ถูก powered off.

Bit 6:0 CAL[6:0]: Calibration value
     ค่านี้แสดงจำนวนของ clock pulses ที่จะถูกเพิกเฉยทุกๆ 2^20 clock pulses. นี้ยอมให้ the calibration ของ the RTC, ทำให้ the
     clock ช้าลงโดยขั้นละ 1000000/2^20 PPM.
     The clock of the RTC สามารถถูกทำให้ช้าลงจาก 0 ถึง 121PPM.

tha



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

Bit 1 TPAL: TAMPER pin active level
     0: A high level บน the TAMPER pin รีเซ็ต data backup registers ทั้งหมด (ถ้า TPE bit ถูถ set).
     1: A low level บน the TAMPER pin รีเซ็ต data backup registers ทั้งหมด (ถ้า TPE bit ถูถ set).

Bit 0 TPE: TAMPER pin enable
     0: The TAMPER pin ถูกปล่อยเป็นอิสระสำหรับ general purpose I/O
     1: Tamper alternate I/O function ถูกทำให้ทำงาน.

Note: การเซ็ต the TPAL และ TPE bits ในเวลาเดียวกันจะปลอดภัยเสมอ, อย่างไรก็ตามการรีเซ็ตทั้งคู่ในเวลาเดียวกันสามารถสร้าง a spurious Tamper event. ด้วยเหตุผลนี้ขอแนะนำให้เปลี่ยน the TPAL bit ได้เพียงเมื่อ the TPE bit ถูก reset เท่านั้น.

tha



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

Bit 9 TIF: Tamper interrupt flag
     บิตนี้ถูกเซ็ตโดย hardware เมื่อ a Tamper event ถูกตรวจจับและ the TPIE bit ถูกเซ็ต. มันถูกเคลียร์โดยการเขียน 1 ไปยัง the
     CTI bit (เคลียร์ the interrupt ด้วย). มันถูกเคลียร์ถ้า the TPIE bit ถูก reset ด้วย.
     0: ไม่มี Tamper interrupt
     1: A Tamper interrupt เกิดขึ้นแล้ว
Note: บิตนี้ถูก reset ได้เพียงโดย a system reset และ wakeup จาก Standby mode.

Bit 8 TEF: Tamper event flag
     บิตนี้ถูกเซ็ตโดย hardware เมื่อ a Tamper event ถูกตรวจจับ. มันถูกเคลียร์โดยการเขียน 1 ไปยัง the CTI bit
     0: ไม่มี Tamper event
     1: A Tamper event เกิดขึ้นแล้ว
Note: A Tamper event รีเซ็ต the BKP_DRx registers ทั้งหมด. พวกมันจะถูกยึดอยู่ใน reset ตราบเท่าที่ the TEF bit ถูก set. ถ้าเขียนไปยัง the BKP_DRx registers ถูกกระทำในขณะที่บิตนี้ถูกเซ็ต, the value จะไม่ถูกจัดเก็บ.

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

Bit 2 TPIE: TAMPER pin interrupt enable
     0: Tamper interrupt ปิดการใช้งานแล้ว
     1: Tamper interrupt เปิดการใช้งานแล้ว (the TPE bit ต้องถูกเซ็ตด้วยใน the BKP_CR register
Note: A Tamper interrupt จะไม่ wake up the core จาก low-power modes.
บิตนี้ถูก reset ได้เพียงโดย a system reset และ wakeup จาก Standby mode.

Bit 1 CTI: Clear tamper interrupt
     บิตนี้ถูกเขียนได้เพียงอย่างเดียว, และถูกอ่านได้เป็น 0 เสมอ.
     0: ไม่มีผลอะไร
     1: เคลียร์ the Tamper interrupt และ the TIF Tamper interrupt flag.

Bit 0 CTE: Clear tamper event
     บิตนี้ถูกเขียนได้เพียงอย่างเดียว, และถูกอ่านได้เป็น 0 เสมอ.
     0: ไม่มีผลอะไร
     1: รีเซ็ต the TEF Tamper event flag (และ the Tamper detector)