1.4.3 Digital General Purpose I/O Control
For pins that are configured as GPIO you can change the values on the pins by using the registers in
.
Table 1-58. GPIO Data Registers
Address
Size (x16) Register Description
Bit Description
GPADAT
0x6FC0
2
GPIO A Data Register (GPIO0-GPIO31)
GPASET
0x6FC2
2
GPIO A Set Register (GPIO0-GPIO31)
GPACLEAR
0x6FC4
2
GPIO A Clear Register (GPIO0-GPIO31)
GPATOGGLE
0x6FC6
2
GPIO A Toggle Register (GPIO0-GPIO31)
GPBDAT
0x6FC8
2
GPIO B Data Register (GPIO32-GPIO58)
GPBSET
0x6FCA
2
GPIO B Set Register (GPIO32-GPIO58)
GPBCLEAR
0x6FCC
2
GPIO B Clear Register (GPIO32-GPIO58)
GPBTOGGLE
0x6FCE
2
GPIO B Toggle Register (GPIO32-GPIO58)
AIODAT
0x6FD8
2
Analog I/O Data Register (AIO0 - AIO15)
AIOSET
0x6FDA
2
Analog I/O Data Set Register (AIO0 - AIO15)
AIOCLEAR
0x6FDC
2
Analog I/O Clear Register (AIO0 - AIO15)
AIOTOGGLE
0x6FDE
2
Analog I/O Toggle Register (AIO0 - AIO15)
(1)
The registers in this table are NOT EALLOW protected.
•
GPxDAT/AIODAT Registers
Each I/O port has one data register. Each bit in the data register corresponds to one GPIO pin. No matter
how the pin is configured (GPIO or peripheral function), the corresponding bit in the data register reflects the
current state of the pin after qualification (This does not apply to AIOx pins). Writing to the GPxDAT/AIODAT
register clears or sets the corresponding output latch and if the pin is enabled as a general purpose output
(GPIO output) the pin will also be driven either low or high. If the pin is not configured as a GPIO output then
the value will be latched, but the pin will not be driven. Only if the pin is later configured as a GPIO output, will
the latched value be driven onto the pin.
When using the GPxDAT register to change the level of an output pin, you should be cautious not to
accidentally change the level of another pin. For example, if you mean to change the output latch level of
GPIOA1 by writing to the GPADAT register bit 0 using a read-modify-write instruction, a problem can occur if
another I/O port A signal changes level between the read and the write stage of the instruction. Following is
an analysis of why this happens:
The GPxDAT registers reflect the state of the pin, not the latch. This means the register reflects the actual
pin value. However, there is a lag between when the register is written to when the new pin value is reflected
back in the register. This may pose a problem when this register is used in subsequent program statements
to alter the state of GPIO pins. An example is shown below where two program statements attempt to drive
two different GPIO pins that are currently low to a high state.
If Read-Modify-Write operations are used on the GPxDAT registers, because of the delay between the output
and the input of the first instruction (I1), the second instruction (I2) will read the old value and write it back.
GpioDataRegs.GPADAT.bit.GPIO1 = 1 ; I1 performs read-modify-write of GPADAT
GpioDataRegs.GPADAT.bit.GPIO2 = 1 ; I2 also a read-modify-write of GPADAT.
; It gets the old value of GPIO1 due to the delay
The second instruction will wait for the first to finish its write due to the write-followed-by-read protection
on this peripheral frame. There will be some lag, however, between the write of (I1) and the GPxDAT bit
reflecting the new value (1) on the pin. During this lag, the second instruction will read the old value of GPIO1
(0) and write it back along with the new value of GPIO2 (1). Therefore, GPIO1 pin stays low.
System Control and Interrupts
SPRUH18I – JANUARY 2011 – REVISED JUNE 2022
TMS320x2806x Microcontrollers
115
Copyright © 2022 Texas Instruments Incorporated
Содержание TMS320 2806 Series
Страница 2: ......