×
单片机 > 单片机程序设计 > 详情

第2天-S3C2440 GPIO

发布时间:2020-05-29 发布时间:
|
General Purpose Input Output (通用输入/输出)简称为GPIO,或总线扩展器,利用工业标准I2C、SMBus或SPI接口简化了I/O口的扩展。当微控制器或芯片组没有足够的I/O端口,或当系统需要采用远端串行通信或控制时,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

 

 

关于如何设定寄存器,请参考芯片手册

关键字:S3C2440  GPIO 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
浅谈AVR中定时器几种工作模式