6.3.6 GPIO locking mechanism
มันเป็นไปได้ที่จะแช่แข็ง the GPIO control registers โดยการนำมาใช้ a specific write sequence กับ the GPIOx_LCKR register. The frozen registers คือ GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
เพื่อเขียน the GPIOx_LCKR register, a specific write / read sequence ต้องถูกนำมาใช้. เมื่อ the right LOCK sequence ถูกนำมาใช้กับ bit 16 ใน register นี้, the value of LCKR[15:0] จะถูกใช้เพือล็อค the configuration ของ the I/Os (ในระหว่าง the write sequence the LCKR[15:0] value ต้องเป็นเหมือนกัน). เมื่อ the LOCK sequence ถูกนำมาใช้กับ a port bit แล้ว, ค่าของ the port bit ไม่สามารถถูกแก้ไขได้อีกต่อไปจนกระทั่ง the next MCU reset หรือ peripheral reset. แต่ละ GPIOx_LCKR bit จะแช่แข็งบิตที่ตรงกันใน the control registers (GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
The LOCK sequence (ดูที่ Section 6.4.8: GPIO port configuration lock register (GPIOx_LCKR) (x = A to K)) สามารถถูกดำเนินการเฉพาะการใช้ a word (32-bit long) เข้าถึงไปยัง the GPIOx_LCKR register เนื่องจากความจริงที่ว่า GPIOx_LCKR bit 16 ต้องถูกเซ็ตในเวลาเดียวกันกับ the [15:0] bits.
สำหรับรายละเอียดเพิ่มเติมดูที่ LCKR register description ใน Section 6.4.8: GPIO port configuration lock register (GPIOx_LCKR) (x = A to K).