使用寄存器MIO_PIN_07.
1. Select MIO pin as GPIO: Set L0_SEL, L1_SEL, L2_SEL, L3_SEL =0 .
2. Set TRI_ENABLE = 0 .
3. LVCMOS18 (refer to the register definition for other voltage options).
4. Slow CMOS edge.
5. Enable internal pull-up resistor.
6. Disable HSTL receiver.
3.2.2寄存器MIO_PIN_07
Register ( slcr) MIO_PIN_07
Name MIO_PIN_07
Relative Address 0x0000071C
Absolute Address 0xF800071C
Width 32 bits
Access Type rw
Reset Value 0x00000601
Description MIO Pin 7 Control
3.2.3寄存器MIO_PIN_50
Name MIO_PIN_50
Relative Address 0x000007C8
Absolute Address 0xF80007C8
Width 32 bits
Access Type rw
Reset Value 0x00001601
Description MIO Pin 50 Control
3.2.4 GPIO设置MIO_PIN_07为输出
使用寄存器DIRM_0
Register ( gpio ) DIRM_0
Name DIRM_0
Software Name DIRM
Relative Address 0x00000204
Absolute Address 0xE000A204
Width 32 bits
Access Type rw
Reset Value 0x00000000
Description Direction mode (GPIO Bank0, MIO)
注:32bit的寄存器对应着32个MIO,将对应的位置设置为1即为输出,我们使用的是MIO_PIN_07,因此寄存器的值应设置为0x00000080.
3.2.5 GPIO设置MIO_PIN_50为输入
使用寄存器DIRM_1
Name DIRM_1
Relative Address 0x00000244
Absolute Address 0xE000A244
Width 22 bits
Access Type rw
Reset Value 0x00000000
Description Direction mode (GPIO Bank1, MIO)
注:22bit的寄存器对应着MIO[53:32],将对应的位置设置为0即为输入,我们使用的是MIO_PIN_50,因此寄存器的值应设置为0x00000080.
3.2.6写入数据到GPIO的输出pin,MIO_PIN_07
MIO_PIN_07为输入,使用的寄存器为DATA_0
Register ( gpio ) DATA_0
Name DATA_0
Software Name DATA
Relative Address 0x00000040
Absolute Address 0xE000A040
Width 32 bits
Access Type rw
Reset Value x
Description Output Data (GPIO Bank0, MIO)
注:32bit的寄存器对应着32个MIO,将对应的位置设置为1即为写入1,我们使用的是MIO_PIN_07,因此寄存器的值应设置为0x00000080.
3.2.7从MIO_PIN_50输出数据
MIO_PIN_50为输出,使用寄存器DATA_1_RO
Name DATA_1_RO
Relative Address 0x00000064
Absolute Address 0xE000A064
Width 22 bits
Access Type ro
Reset Value x
Description Input Data (GPIO Bank1, MIO)
注:22bit寄存器对应着MIO[53:32],可以直接从此寄存器中读取对应PIN输入的数据.