第2天-S3C2440 GPIO
S3C2440A has 130 multi-functional input/output port pins and there are eight ports as shown below:
— Port A(GPA): 25-output port
— Port B(GPB): 11-input/out port
— Port C(GPC): 16-input/output port
— Port D(GPD): 16-input/output port
— Port E(GPE): 16-input/output port
— Port F(GPF): 8-input/output port
— Port G(GPG): 16-input/output port
— Port H(GPH): 9-input/output port
— Port J(GPJ): 13-input/output port
Each port can be easily configured by software to meet various system configurations and design requirements. You have to define which function of each pin is used before starting the main program. If a pin is not used for multiplexed functions, the pin can be configured as I/O ports
从上面的信息可以看出,S3C2440芯片共有130个GPIO引脚,分为9组
关于GPIO的寄存器
1. GPxCON 寄存器
用于配置引脚功能。 Configure PORT A 与 PORT B~PORT H/J 在功能选择上有所不同,GPACON 中每一位对应一根引脚,共 23 个引脚。当某位被设为 0 时候,相应引脚为 输出引脚。此时我们可以在GPADAT 中相应的写入 1或者 0 来让此引脚输出高电平或者低电平;当某位被设为1时,相应引脚为地址线或用于地址控制,此时GPADATA无用。一般而言 GPACON 通常被设为 1 ,以便访问外部器件。
PORT B~PORT H/J
在寄存器操作方面完全相同,GPxCON 中每两位控制一根引脚,
00 输入 01 输出
10 特殊功能 11 保留不用
2. GPxDAT 寄存器
GPxDAT用于读写引脚,当引脚被设为输入时候,读此寄存器可知道相应引脚的电平状态高还是低,当引脚被设为输出时候,写此寄存器的位,可令引脚输出高电平还是低电平。
3. GPxUP寄存器
GPxUP寄存器某位为1的时候,相应管脚没有内部上拉电阻;为 0 时候 相应管脚有内部上拉电阻。
上拉电阻作用在于,当GPIO 引脚处于第三种状态时候,既不是输出高电平,也不是输出低电平。而是呈现高阻态,相当于没有接芯片。它的电平状态由上下拉电阻决定。
S3C2440中关于寄存器的英文介绍如下:
PORT CONFIGURATION REGISTER (GPACON-GPJCON)
In S3C2440A, most of the pins are multiplexed pins. So, It is determined which function is selected for each pins.
The PnCON(port control register) determines which function is used for each pin.
If PE0 – PE7 is used for the wakeup signal in power down mode, these ports must be configured in interrupt mode.
PORT DATA REGISTER (GPADAT-GPJDAT)
If Ports are configured as output ports, data can be written to the corresponding bit of PnDAT. If Ports are configured
as input ports, the data can be read from the corresponding bit of PnDAT.
PORT PULL-UP REGISTER (GPBUP-GPJUP)
The port pull-up register controls the pull-up resister enable/disable of each port group. When the corresponding bit is
0, the pull-up resister of the pin is enabled. When 1, the pull-up resister is disabled.
If the port pull-up register is enabled then the pull-up resisters work without pin’s functional setting(input, output,
DATAn, EINTn and etc
关于如何设定寄存器,请参考芯片手册
S3C2440GPI 相关文章:
- ARM9 S3C2440—GPIO初始化设置(11-28)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)