MAX32665-MAX32668 User Guide
Maxim Integrated Page 123 of 457
6.2 Usage
6.2.1 Reset State
During a power-on-reset event, each GPIO is reset to the default input mode with the weak pullup resistor enabled as
follows:
• The GPIO Configuration Enable bits shown in Table 6-3 are set to I/O (transition to AF1) mode.
• Input mode is enabled (GPIOn_IN_EN[pin] = 1).
• High impedance mode enabled (GPIOn_PDPU_SEL0[pin] = 0, GPIOn_PDPU_SEL1[pin] = 0), pullup and pulldown
disabled.
• Output mode disabled (GPIOn_OUT_EN[pin] = 0)
• Interrupt disabled (GPIOn_INT_EN[pin] = 0)
6.2.2 Input Mode Configuration
Perform the following steps to configure one or more pins for input mode:
1. Set the GPIO Configuration Enable bits shown in Table 6-3 to any one of the I/O mode settings.
2. Configure the electrical characteristics of the pin as desired as shown in Table 6-4.
3. Enable the input buffer connection to the GPIO pin by setting GPIOn_IN_EN[pin] to 1.
4. Read the input state of the pin using the GPIOn_IN[pin] field.
6.2.3 Output Mode Configuration
Perform the following steps to configure a pin for output mode:
1. Set the GPIO Configuration Enable bits shown in Table 6-3 to any one of the I/O mode settings.
2. Configure the electrical characteristics of the pin as desired as shown in Table 6-5
3. Set the output high or low using the GPIOn_OUT[pin] bit.
4. Enable the output buffer for the pin by setting GPIOn_OUT_EN[pin] to 1.
6.2.4 Alternate Function Configuration
Most GPIO support one or more alternate functions which are selected with the GPIO Configuration Enable bits shown in
Table 6-3. The bits that select the AF must only be changed while the pin is in one of the I/O modes (GPIOn_EN0 = 1). The
specific I/O mode must match the desired AF. For example, if a transition to AF1 is desired, first select the setting
corresponding to I/O (transition to AF1). Then enable the desired mode by selecting the AF1 mode.
1. Set the GPIO Configuration Enable bits shown in Table 6-3 to the I/O mode that corresponds with the desired new
AF setting. For example, select “I/O (transition to AF1)” if switching to AF1. Switching between different I/O mode
settings will not affect the state or electrical characteristics of the pin.
2. Configure the electrical characteristics of the pin. See Table 6-4 if the assigned alternate function will use the pin as
an input. See Table 6-5 if the assigned alternate function will use the pin as an output.
3. Set the GPIO Configuration Enable bits shown in Table 6-3 to the desired alternate function.
6.3 Configuring GPIO (External) Interrupts
Each GPIO pin supports external interrupt events when the GPIO is configured for I/O mode and the input mode is enabled.
If the GPIO is configured as a peripheral alternate function, the interrupts are peripheral-controlled.
GPIO interrupts can be individually enabled and configured as an edge or level triggered independently on a pin-by-pin
basis. The edge trigger can be a rising, falling, or both transitions.