SPRUJ17H March 2022 – October 2024 AM2631 , AM2631-Q1 , AM2632 , AM2632-Q1 , AM2634 , AM2634-Q1
Each GPIO pin (GPj) can be independently configured as either an input or an output using the GPIO direction registers. The GPIO direction register (DIR) specifies the direction of each GPIO signal. Logic 0 indicates the GPIO pin is configured as output, and logic 1 indicates input.
When configured as output, writing a 0x1 to a bit in the set data register drives the corresponding GPj to a logic-high state. Writing a 0x1 to a bit in the clear data register drives the corresponding GPj to a logic-low state. The output state of each GPj can also be directly controlled by writing to the output data register.
For example, to set GP8 to a logic-high state, the software can perform one of the following sequences:
Write 0h to the bit 8 of GPIO_DIR01 register to configure as output pin.
Note that writing a 0x0 to bits in the set data and clear data registers does not affect the GPIO pin state.
Also, for GPIO pins configured as input, writing to the set data, clear data, or output data registers does not affect the pin state.
For a GPIO pin configured as input, reading the input data register (IN_DATA) will return the pin state. Reading the SET_DATA register or the CLR_DATA data register will return the value in OUT_DATA, not the actual pin state. The pin state is available by reading the input data register. Note that when the direction is configured as input, the output state is determined by software’s programming set/clear/output registers, and may not agree with the pin state, which is driven by an external device.