Difference between revisions of "STM32F107VC/GPIO"
m (→Port Bit Configuration) |
m (→Port Bit Configuration) |
||
Line 38: | Line 38: | ||
! colspan=2 |Configuration mode !! CNF1 !! CNF0 !! MODE1 !! MODE0 !! PxODR register | ! colspan=2 |Configuration mode !! CNF1 !! CNF0 !! MODE1 !! MODE0 !! PxODR register | ||
|- align=center | |- align=center | ||
− | |rowspan=2 |General Purpose Output ||Push-Pull||rowspan=2; |0||0||rowspan=4; colspan=2|00<br/>01<br/>10<br/>|| 0 or 1 | + | |rowspan=2 align=left|General Purpose Output || align=left |Push-Pull||rowspan=2; |0||0||rowspan=4; colspan=2|00<br/>01<br/>10<br/>|| 0 or 1 |
|- align=center | |- align=center | ||
− | |Open Drain ||1|| 0 or 1 | + | | align=left |Open Drain ||1|| 0 or 1 |
|- align=center | |- align=center | ||
− | |rowspan=2 |Alternate function Output ||Push-Pull||rowspan=2; |1||0|| Dont Care | + | |rowspan=2 align=left |Alternate function Output || align=left |Push-Pull||rowspan=2; |1||0|| Dont Care |
|- align=center | |- align=center | ||
− | |Open Drain ||1|| Dont Care | + | | align=left |Open Drain ||1|| Dont Care |
|- align=center | |- align=center | ||
− | |rowspan=4 |Input ||Analog||rowspan=2; |0||0||rowspan=4; colspan=2|00|| Dont Care | + | |rowspan=4 align=left |Input || align=left |Analog||rowspan=2; |0||0||rowspan=4; colspan=2|00|| Dont Care |
|- align=center | |- align=center | ||
− | | Input Floating|| 1 || Dont Care | + | | align=left |Input Floating|| 1 || Dont Care |
|- align=center | |- align=center | ||
− | | Input Pull-Down|| rowspan=2 | 1 || rowspan=2 | 0 || 0 | + | | align=left |Input Pull-Down|| rowspan=2 | 1 || rowspan=2 | 0 || 0 |
|- align=center | |- align=center | ||
− | | Input Pull-Up|| 1 | + | | align=left |Input Pull-Up|| 1 |
|- | |- | ||
− | |||
|} | |} | ||
Revision as of 08:28, 28 August 2011
General Purpose and Alternate Function I/O
GPIO functional description
Each of the general-purpose I/O ports has two 32-bit configuration registers (GPIOx_CRL, GPIOx_CRH), two 32-bit data registers (GPIOx_IDR, GPIOx_ODR), a 32-bit set/reset register (GPIOx_BSRR), a 16-bit reset register (GPIOx_BRR) and a 32-bit locking register (GPIOx_LCKR).
Subject to the specific hardware characteristics of each I/O port listed in the datasheet, each port bit of the General Purpose IO (GPIO) Ports, can be individually configured by software in several modes:
- Input floating
- Input pull-up
- Input-pull-down
- Analog
- Output open-drain
- Output push-pull
- Alternate function push-pull
- Alternate function open-drain
Each I/O port bit is freely programmable, however the I/O port registers have to be accessed as 32-bit words (half-word or byte accesses are not allowed). The purpose of the GPIOx_BSRR and GPIOx_BRR registers is to allow atomic read/modify accesses to any of the GPIO registers. This way, there is no risk that an IRQ occurs between the read and the modify access.
Default configuration
During and just after reset, the alternate functions are not active and the I/O ports are configured in Input Floating mode.
Port Bit Configuration
Each bit can be configured using the configuration registers shown below
Name | Function |
---|---|
A | A |
B | B |
Configuration mode | CNF1 | CNF0 | MODE1 | MODE0 | PxODR register | |
---|---|---|---|---|---|---|
General Purpose Output | Push-Pull | 0 | 0 | 00 01 10 |
0 or 1 | |
Open Drain | 1 | 0 or 1 | ||||
Alternate function Output | Push-Pull | 1 | 0 | Dont Care | ||
Open Drain | 1 | Dont Care | ||||
Input | Analog | 0 | 0 | 00 | Dont Care | |
Input Floating | 1 | Dont Care | ||||
Input Pull-Down | 1 | 0 | 0 | |||
Input Pull-Up | 1 |
Detailed description
For detailed description see STM32F107VC Reference Manual Chapter 9.