新聞中心

第2天-S3C2440 GPIO

作者: 時間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
General Purpose Input Output (通用輸入/輸出)簡稱為GPIO,或總線擴展器,利用工業(yè)標(biāo)準I2C、SMBus或SPI接口簡化了I/O口的擴展。當(dāng)微控制器或芯片組沒有足夠的I/O端口,或當(dāng)系統(tǒng)需要采用遠端串行通信或控制時,GPIO產(chǎn)品能夠提供額外的控制和監(jiān)視功能。

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

本文引用地址:http://m.butianyuan.cn/article/201611/321983.htm

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組

關(guān)于GPIO的寄存器

1. GPxCON 寄存器
用于配置引腳功能。 Configure PORT A 與 PORT B~PORT H/J 在功能選擇上有所不同,GPACON 中每一位對應(yīng)一根引腳,共 23 個引腳。當(dāng)某位被設(shè)為 0 時候,相應(yīng)引腳為 輸出引腳。此時我們可以在GPADAT 中相應(yīng)的寫入 1或者 0 來讓此引腳輸出高電平或者低電平;當(dāng)某位被設(shè)為1時,相應(yīng)引腳為地址線或用于地址控制,此時GPADATA無用。一般而言 GPACON 通常被設(shè)為 1 ,以便訪問外部器件。
PORT B~PORT H/J
在寄存器操作方面完全相同,GPxCON 中每兩位控制一根引腳,
00 輸入 01 輸出
10 特殊功能 11 保留不用
2. GPxDAT 寄存器
GPxDAT用于讀寫引腳,當(dāng)引腳被設(shè)為輸入時候,讀此寄存器可知道相應(yīng)引腳的電平狀態(tài)高還是低,當(dāng)引腳被設(shè)為輸出時候,寫此寄存器的位,可令引腳輸出高電平還是低電平。
3. GPxUP寄存器
GPxUP寄存器某位為1的時候,相應(yīng)管腳沒有內(nèi)部上拉電阻;為 0 時候 相應(yīng)管腳有內(nèi)部上拉電阻。
上拉電阻作用在于,當(dāng)GPIO 引腳處于第三種狀態(tài)時候,既不是輸出高電平,也不是輸出低電平。而是呈現(xiàn)高阻態(tài),相當(dāng)于沒有接芯片。它的電平狀態(tài)由上下拉電阻決定。
S3C2440中關(guān)于寄存器的英文介紹如下:

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

關(guān)于如何設(shè)定寄存器,請參考芯片手冊



關(guān)鍵詞: S3C2440GPI

評論


技術(shù)專區(qū)

關(guān)閉