STM32F1 GPIO

Started by tha, November 15, 2020, 09:29:02 AM

Previous topic - Next topic

tha



Bits 31:16 BRy: Port x Reset bit y (y= 0 .. 15)
     บิตเหล่านี้เขียนได้เพียงอย่างเดียวและสามารถถูกเข้าถึงใน Word mode เท่านั้น.
     0: ไม่มีการทำอะไรบน the corresponding ODRx bit
     1: Reset the corresponding ODRx bit
Note: ถ้าทั้ง BSx และ BRx ถูก set, BSx มีลำดับความสำคัญ(ที่สูงกว่า)

Bits 15:0 BSy: Port x Set bit y (y= 0 .. 15)
     บิตเหล่านี้เขียนได้เพียงอย่างเดียวและสามารถถูกเข้าถึงใน Word mode เท่านั้น.
     0: ไม่มีการทำอะไรบน the corresponding ODRx bit
     1: Set the corresponding ODRx bit

tha



Bits 31:16 Reserved

Bits 15:0 BRy: Port x Reset bit y (y= 0 .. 15)
     บิตเหล่านี้เขียนได้เพียงอย่างเดียวและสามารถถูกเข้าถึงใน Word mode เท่านั้น.
     0: No action on the corresponding ODRx bit
     1: Reset the corresponding ODRx bit

tha

9.2.7 Port configuration lock register (GPIOx_LCKR) (x=A..G)
register นี้ถูกใช้เพื่อล็อค the configuration ของ the port bits เมื่อ a correct write sequence ถูกนำไปใช้กับ bit 16 (LCKK). ค่าของ bits [15:0] ถูกใช้เพื่อล็อค the configuration ของ the GPIO. ในระหว่าง the write sequence, ค่าของ LCKR[15:0] ต้องไม่ถูกเปลี่ยน. เมื่อ the LOCK sequence ถูกนำไปใช้บน a port bit แล้วมันไม่สามารถที่จะแก้ไขค่าของ the port bit ได้อีกต่อไปจนกระทั่งการรีเซ็ตถัดไป.

แต่ละ lock bit จะแช่แข็ง the corresponding 4 bits ของ the control register (CRL, CRH).

Address offset: 0x18
Reset value: 0x0000 0000



Bits 31:17 Reserved

Bit 16 LCKK[16]: Lock key
บิตนี้สามารถถูกอ่านได้ตลอดเวลา. มันสามารถถูกแก้ไขได้เพียงการใช้ the Lock Key Writing Sequence.
     0: Port configuration lock key ไม่ active
     1: Port configuration lock key active. GPIOx_LCKR register ถูกล็อคจนกระทั่ง the next reset.

LOCK key writing sequence:
     Write 1
     Write 0
     Write 1
     Read 0
     Read 1(การอ่านนี้เป็นทางเลือก แต่ยืนยันว่าการล็อกทำงานอยู่)
Note: ในระหว่าง the LOCK Key Writing sequence, ค่าของ LCKR[15:0] ต้องไม่ถูกเปลี่ยน. ข้อผิดพลาดใด ๆใน the lock sequence จะยกเลิก the lock.

Bits 15:0 LCKy: Port x Lock bit y (y= 0 .. 15)
บิตเหล่านี้ถูกอ่านเขียนได้แต่สามารถถูกเขียนได้เพียงเมื่อ the LCKK bit เป็น 0.
     0: Port configuration ไม่ locked
     1: Port configuration locked


tha

9.3 Alternate function I/O and debug configuration (AFIO)
เพื่อทำจำนวนของ peripheral ให้เหมาะที่สุดที่มีให้ใช้สำหรับ the 64-pin หรือ the 100-pin หรือ the 144-pin package, มันสามารถที่จะเปลี่ยนขา(remap) บาง alternate functions ไปยังบางพินอื่นๆ. นี้ถูกทำให้สำเร็จลงโดย software, โดยการโปรแกรม he AF remap and debug I/O configuration register (AFIO_MAPR).. ในกรณีนี้, the alternate functions จะไม่ถูก mapped เข้ากับการกำหนดเดิม(original assignations) อีกต่อไป

tha

9.3.1 การใช้ OSC32_IN/OSC32_OUT pins เป็น GPIO ports PC14/PC15
The LSE oscillator pins OSC32_IN และ OSC32_OUT สามารถถูกใช้เป็น general-purpose I/O PC14 และ PC15, ตามลำดับ, เมื่อ the LSE oscillator ถูก off. The LSE มีลำดับความสำคัญเหนือ the GP IOs function.

Note: The PC14/PC15 GPIO functionality จะหายไปเมื่อ the 1.8 V domain ถูก powered off (โดยการเข้าสู่ standby mode) หรือเมื่อ the backup domain ถูกจ่ายไฟโดย VBAT (VDD ไม่ได้จ่ายไฟอีกต่อไป). ในกรณีนี้ the IOs นี้จะถูกเซ็ตใน analog mode.

อ้างอิงถึงหมายเหตุข้อจำกัดการใช้ IO (IO usage restrictions) ใน Section 5.1.2: Battery backup domain.

tha

9.3.2 Using OSC_IN/OSC_OUT pins as GPIO ports PD0/PD1
The HSE oscillator pins OSC_IN/OSC_OUT สามารถถูกใช้เป็น general-purpose I/O PD0/PD1 โดยการโปรแกรม the PD01_REMAP bit ใน the AF remap and debug I/O configuration register (AFIO_MAPR).

การเปลี่ยนขา(remap)นี้มีให้ใช้เพียงบน 36-, 48- และ 64-pin packages (PD0 และ PD1 มีให้ใช้บน 100-pin and 144-pin packages, ไม่มีความจำเป็นสำหรับการเปลี่ยนขา).

Note: The external interrupt/event function ไม่ถูก remapped. PD0 and PD1 ไม่สามารถถูกใช้สำหรับ external interrupt/event generation บน 36-, 48- and 64-pin packages.

tha

9.3.3 CAN1 alternate function remapping
The CAN signals สามารถถูก mapped บน Port A, Port B หรือ Port D ดังแสดงใน Table 34. สำหรับ port D, การเปลี่ยนขาไม่สามารถเป็นได้ใน devices ที่จัดส่งใน 36-, 48- and 64-pin packages.



1. CAN1_RX and CAN1_TX ใน connectivity line devices; CAN_RX and CAN_TX ใน devices อื่นๆที่มี a single CAN interface.
2. Remap ไม่มีให้ใช้บน 36-pin package
3. การเปลี่ยนขานี้มีให้ใช้เพียงบน 100-pin and 144-pin packages, เมื่อ PD0 และ PD1 ไม่ได้ถูกเปลี่ยนขาบน OSC-IN and OSC-OUT

tha

9.3.4 CAN2 alternate function remapping
CAN2 มีให้ใช้ใน connectivity line devices. The external signal สามารถถูกเปลี่ยนขาดังแสดงใน Table 35.