S3C2440有GPA,GPB,GPC......GPJ一共9组,比2410多了一组<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
GPIO无非是用来进行输入输出的,那么肯定有寄存器进行控制
对于输入的话,我们一定可以通过读取寄存器来确定引脚的高电平还是低电平;
对于输出的话,我们一定也可以通过写某个寄存器来让这个引脚输出高低电平.
1控制类的:
GPxCON
portA有点与众不同啊,GPACON每一位对应着一根引脚(23根)
0:代表输出;1:相应的引脚为地址线或用于地址控制
对于PORT B-PORT J的话,GPxCON中每两位控制一根引脚
00:输入;01:输出;10:特殊功能;11:保留
2.数据
GPxDAT
用于读或者写
3.GPxUP
1:不使用内部的上拉电阻;0:使用内部上拉电阻
从手册中可以得知(原来很多东西都可以查手册的):
GPACON 0x56000000 ← W R/W Port A Control
GPADAT 0x56000004 Port A Data
GPBCON 0x56000010 Port B Control
GPBDAT 0x56000014 Port B Data
GPBUP 0x56000018 Pull-up Control B
GPCCON 0x56000020 Port C Control
GPCDAT 0x56000024 Port C Data
GPCUP 0x56000028 Pull-up Control C
GPDCON 0x56000030 Port D Control
GPDDA1T 0x56000034 Port D Data
GPDUP 0x56000038 Pull-up Control D
GPECON 0x56000040 Port E Control
GPEDAT 0x56000044 Port E Data
GPEUP 0x56000048 Pull-up Control E
GPFCON 0x56000050 Port F Control
GPFDAT 0x56000054 Port F Data
GPFUP 0x56000058 Pull-up Control F
GPGCON 0x56000060 Port G Control
GPGDAT 0x56000064 Port G Data
GPGUP 0x56000068 Pull-up Control G
GPHCON 0x56000070 Port H Control
GPHDAT 0x56000074 Port H Data
GPHUP 0x56000078 Pull-up Control H
GPJCON 0x560000D0 Port J Control
GPJDAT 0x560000D4 Port J Data
GPJUP 0x560000D8 Pull-up Control J
GPIO操作实例:LED与按键
GPFCON Bit Description
GPF7 [15:14] 00 = Input 01 = Output
10 = EINT[7] 11 = Reserved
GPF6 [13:12] 00 = Input 01 = Output
10 = EINT[6] 11 = Reserved
GPF5 [11:10] 00 = Input 01 = Output
10 = EINT[5] 11 = Reserved
GPF4 [9:8] 00 = Input 01 = Output
10 = EINT[4] 11 = Reserved
GPF3 [7:6] 00 = Input 01 = Output
10 = EINT[3] 11 = Reserved
GPF2 [5:4] 00 = Input 01 = Output
10 = EINT2] 11 = Reserved
GPF1 [3:2] 00 = Input 01 = Output
10 = EINT[1] 11 = Reserved
GPF0 [1:0] 00 = Input 01 = Output
10 = EINT[0] 11 = Reserved
怎么想都觉得书上莫名其妙,查了一下确实有错。
@******************************************************************************
@ File:led_on.S
@ 功能:LED点灯程序,点亮LED1
@******************************************************************************
.text
.global _start
_start:
LDR R0,=0x56000050 @ R0设为GPFCON寄存器。此寄存器
@ 用于选择端口F各引脚的功能:
@ 是输出、是输入、还是其他
MOV R1,#0x00000100
STR R1,[R0] @ 设置GPF4为输出口, 位[9:8]=0b01
LDR R0,=0x56000054 @ R0设为GPFDAT寄存器。此寄存器
@ 用于读/写端口F各引脚的数据
MOV R1,#0x00000000 @ 此值改为0x00000010,
@ 可让LED1熄灭
STR R1,[R0] @ GPF4输出0,LED1点亮
MAIN_LOOP:
B MAIN_LOOP
文章评论(0条评论)
登录后参与讨论