GPIO Function
2 GPIO Function
You can independently configure each GPIO pin (GPn) 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 1 to a bit in the set data register drives the corresponding GPn to a
-Write 0x100 to the SET_DATA register
-Read in OUT_DATA register, change the eighth bit to 1, and write the new value back to OUT_DATA
To set GP8 to a
-Write 0x100 to the CLR_DATA register
-Read in OUT_DATA register, change the eighth bit to 0, and write the new value back to OUT_DATA
Note that writing a 0 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.
12 | SPRU724 |