STM32F1 GPIO

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

Previous topic - Next topic

tha

9.4 AFIO registers
อ้างอิงถึง Section 2.2 บนหน้า 45 สำหรับรายการของตัวย่อที่ใช้ใน register descriptions.

Note: เพื่อ read/write the AFIO_EVCR, AFIO_MAPR and AFIO_EXTICRX registers, the AFIO clock ควรถูกเปิดการใช้งานเป็นอันดับแรก. อ้างอิงถึง Section 7.3.7: APB2 peripheral clock enable register(RCC_APB2ENR).

The peripheral registers ต้องถูกเข้าถึงโดย words (32-bit).



Bits 31:8 Reserved

Bit 7 EVOE: Event output enable
เซ็ตและเคลียร์โดย software. เมื่อเซ็ต the EVENTOUT Cortex® output ถูกต่อไปยัง the I/O ที่เลือกโดย the PORT[2:0] และ PIN[3:0] bits.

Bits 6:4 PORT[2:0]: Port selection
เซ็ตและเคลียร์โดย software. เลือก the port ที่ใช้เพื่อส่งออก the Cortex® EVENTOUT signal.
Note: The EVENTOUT signal output capability ไม่ได้ถูกต่อไปยัง ports PF และ PG.
     000: PA ถูกเลือก
     001: PB selected
     010: PC selected
     011: PD selected
     100: PE selected

Bits 3:0 PIN[3:0]: Pin selection (x = A .. E)
เซ็ตและเคลียร์โดย software. เลือก the pin ที่ใช้เพื่อส่งออก the Cortex® EVENTOUT signal.
     0000: Px0 ถูกเลือก
     0001: Px1 selected
     0010: Px2 selected
     0011: Px3 selected
     ...
     1111: Px15 selected

tha



Bits 31:27 Reserved

Bits 26:24 SWJ_CFG[2:0]: Serial wire JTAG configuration
บิตเหล่านี้เขียนได้เพียงอย่างเดียว (เมื่ออ่าน, ค่าที่ได้จะนิยามไม่ได้). มันถูกใช้เพื่อกำหนด the SWJ และ trace alternate function I/Os. The SWJ (Serial Wire JTAG) รองรับ JTAG หรือ SWD เข้าถึงยัง Cortex® debug port. สถานะเริ่มต้นหลังจาก reset คือ SWJ ON โดยปราศจาก trace. นี้ยอมให้ JTAG หรือ SW mode ถูกเปิดการใช้งานโดยการส่ง a specific sequence ไปบน the JTMS /JTCK pin.
     000: Full SWJ (JTAG-DP + SW-DP): Reset State
     001: Full SWJ (JTAG-DP + SW-DP) แต่ปราศจาก NJTRST
     010: JTAG-DP ถูกปิดการใช้งาน และ SW-DP ถูกเปิดการใช้งาน
     100: JTAG-DP ถูกปิดการใช้งาน และ SW-DP ถูกปิดการใช้งาน
     การรวมอย่างอื่น : ไม่มีผลอะไร

Bits 23:21 Reserved.

Bits 20 ADC2_ETRGREG_REMAP: ADC 2 external trigger regular conversion remapping
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the trigger input ที่ต่อไปยัง ADC2 external trigger regular conversion. เมื่อบิตนี้ถูก reset, the ADC2 external trigger regular conversion ถูกต่อไปยัง EXTI11.  เมื่อบิตนี้ถูก set, the ADC2 external event regular conversion ถูกต่อไปยัง TIM8_TRGO.

Bits 19 ADC2_ETRGINJ_REMAP: ADC 2 external trigger injected conversion remapping
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the trigger input ที่ต่อไปยัง ADC2 external trigger injected conversion. เมื่อบิตนี้ถูก reset, the ADC2 external trigger injected conversion ถูกต่อไปยัง EXTI15. เมื่อบิตนี้ถูก set, the ADC2 external event injected conversion ถูกต่อไปยัง TIM8_Channel4.

Bits 18 ADC1_ETRGREG_REMAP: ADC 1 external trigger regular conversion remapping
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the trigger input ที่ต่อไปยัง ADC1 External trigger regular conversion. เมื่อ reset the ADC1 External trigger regular conversion ถูกต่อไปยัง EXTI11. เมื่อ set the ADC1 External Event regular conversion ถูกต่อไปยัง TIM8 TRGO.

tha

Bits 17 ADC1_ETRGINJ_REMAP: ADC 1 External trigger injected conversion remapping
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the trigger input ที่ต่อไปยัง ADC1 External trigger injected conversion. เมื่อ reset the ADC1 External trigger injected conversion ถูกต่อไปยัง EXTI15. เมื่อ set the ADC1 External Event injected conversion ถูกต่อไปยัง TIM8 Channel4.

Bits 16 TIM5CH4_IREMAP: TIM5 channel4 internal remap
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the TIM5_CH4 การ mapping ถึงกันภายใน. เมื่อ reset the timer TIM5_CH4 ถูกต่อไปยัง PA3. เมื่อ set the LSI internal clock ถูกต่อไปยัง TIM5_CH4 input สำหรับ calibration purpose.
Note: บิตนี้มีให้ใช้เพียงใน high density value line devices.

Bit 15 PD01_REMAP: Port D0/Port D1 mapping on OSC_IN/OSC_OUT
เซ็ตและเคลียร์โดย software. บิตนี้ควบคุม the mapping ของ PD0 and PD1 GPIO functionality. เมื่อ the HSE oscillator ไม่ได้ถูกใช้ (application รันบน internal 8 MHz RC) PD0 และ PD1 สามารถถูก mapped บน OSC_IN และ OSC_OUT. นี้มีให้ใช้เพียงบน 36-, 48- และ 64-pin packages (PD0 and PD1 มีให้ใช้บน 100-pin and 144-pin packages, ไม่จำเป็นสำหรับการ remapping).
     0: ไม่มีการ remapping ของ PD0 and PD1
     1: PD0 remapped on OSC_IN, PD1 remapped on OSC_OUT,


tha

Bits 14:13 CAN_REMAP[1:0]: CAN alternate function remapping
บิตเหล่านี้เซ็ตและเคลียร์โดย software. มันควบคุม the mapping ของ alternate functions CAN_RX และ CAN_TX ใน devices ที่มี a single CAN interface.
     00: CAN_RX mapped to PA11, CAN_TX mapped to PA12
     01: ไม่ใช้
     10: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (ไม่มีให้ใช้บน 36-pin package)
     11: CAN_RX mapped to PD0, CAN_TX mapped to PD1

Bit 12 TIM4_REMAP: TIM4 remapping
บิตนี้เซ็ตและเคลียร์โดย software. มันควบคุม the mapping ของ TIM4 channels 1 ถึง 4 ไปบน the GPIO ports.
     0: No remap (TIM4_CH1/PB6, TIM4_CH2/PB7, TIM4_CH3/PB8, TIM4_CH4/PB9)
     1: Full remap (TIM4_CH1/PD12, TIM4_CH2/PD13, TIM4_CH3/PD14, TIM4_CH4/PD15)
Note: TIM4_ETR บน PE0 ไม่ถูก re-mapped.

Bits 11:10 TIM3_REMAP[1:0]: TIM3 remapping
บิตเหล่านี้เซ็ตและเคลียร์โดย software. มันควบคุม the mapping ของ TIM3 channels 1 ถึง 4 บน the GPIO ports.
     00: No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1)
     01: Not used
     10: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1)
     11: Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9)
Note: TIM3_ETR บน PE0 ไม่ถูก re-mapped.

Bits 9:8 TIM2_REMAP[1:0]: TIM2 remapping
บิตเหล่านี้เซ็ตและเคลียร์โดย software. มันควบคุม the mapping ของ TIM2 channels 1 ถึง 4 และ external trigger (ETR) บน the GPIO ports.
     00: No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3)
     01: Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3)
     10: Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11)
     11: Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11)

tha

Bits 7:6 TIM1_REMAP[1:0]: TIM1 remapping
These bits are set and cleared by software. They control the mapping of TIM1 channels 1 to
4, 1N to 3N, external trigger (ETR) and Break input (BKIN) on the GPIO ports.
     00: No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12,
           CH1N/PB13, CH2N/PB14, CH3N/PB15)
     01: Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6,
          CH1N/PA7, CH2N/PB0, CH3N/PB1)
     10: not used
     11: Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15,
          CH1N/PE8, CH2N/PE10, CH3N/PE12)

Bits 5:4 USART3_REMAP[1:0]: USART3 remapping
These bits are set and cleared by software. They control the mapping of USART3 CTS,
RTS,CK,TX and RX alternate functions on the GPIO ports.
     00: No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14)
     01: Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14)
     10: not used
     11: Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12)

Bit 3 USART2_REMAP: USART2 remapping
This bit is set and cleared by software. It controls the mapping of USART2 CTS, RTS,CK,TX
and RX alternate functions on the GPIO ports.
     0: No remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4)
     1: Remap (CTS/PD3, RTS/PD4, TX/PD5, RX/PD6, CK/PD7)

Bit 2 USART1_REMAP: USART1 remapping
This bit is set and cleared by software. It controls the mapping of USART1 TX and RX
alternate functions on the GPIO ports.
     0: No remap (TX/PA9, RX/PA10)
     1: Remap (TX/PB6, RX/PB7)

Bit 1 I2C1_REMAP: I2C1 remapping
This bit is set and cleared by software. It controls the mapping of I2C1 SCL and SDA
alternate functions on the GPIO ports.
     0: No remap (SCL/PB6, SDA/PB7)
     1: Remap (SCL/PB8, SDA/PB9)

Bit 0 SPI1_REMAP: SPI1 remapping
This bit is set and cleared by software. It controls the mapping of SPI1 NSS, SCK, MISO,
MOSI alternate functions on the GPIO ports.
     0: No remap (NSS/PA4, SCK/PA5, MISO/PA6, MOSI/PA7)
     1: Remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5)

tha






ปล. มันก็เหมือนกันแหละ คงจะเข้าใจกันแล้ว ขอไม่แปลนะ จะได้ไปไวๆ

tha



Bits 31:16 Reserved

Bits 15:0 EXTIx[3:0]: EXTI x configuration (x= 0 to 3)
บิตเหล่านี้ถูกเขียนโดย software เพื่อเลือก the source input สำหรับ EXTIx external interrupt.
อ้างอิงถึง Section 10.2.5: External interrupt/event line mapping




Bits 31:16 Reserved

Bits 15:0 EXTIx[3:0]: EXTI x configuration (x= 4 to 7)
บิตเหล่านี้ถูกเขียนโดย software เพื่อเลือก the source input สำหรับ EXTIx external interrupt.

tha