You are on page 1of 4

ARM7

Advance RISC Machine GPIO FEATURES: Direction control of individual bits Separate control of output set and clear All I/O default to inputs after reset

ARM 7 has two port named as Port 0 and Port 1. Each port can be used as I/P or O/P. Port 0 has 0-31 pins and Port1 has 16-31 pins. Each Port can be used as GPIO(general purpose I/p and O/p) or As SFR(Special Function). 1. To use it as GPIO we have to set some register. PINSEL0----it must be 0 to use LSB of port 0 as GPIO(0-15) PINSEL1---it must be 0 to use MSB of port 0 as GPIO(16-31) PINSEL2---it must be 0 to use Port 1 as GPIO 2. To set the direction of any Port as I/P or O/P we have to SET and CLR a Register named as IODIR 1---set as o/p 0---set as i/p Example: IO0DIR=0x00000000; // it means port 0 will act as i/p IO1DIR=0x000000ff; // it means lower 8 bit of port 1 will act as o/p 3. Now Lets Put some data on register. For that we are using two register IOSET and IOCLR. As its name shows it can set and clear particular data bit. Example: IO0SET=0x00000001; //it means 0th bit of Port 0 will be set IO0CLR=0x00000001; //it means 0th bit of Port 0 will be cleared

www.embbsys.blogspot.in

Power supply ckt of ARM

ARM requires two power supply one is for CPU(+1.6 to 1.95v) and other is for I/O(+3 to 3.6v)

Now its Time for a HELLO WORLD Program //this is written in Keil uvision v 4.0 and for LPC2124(ARM7 TDMI)// // I am going to blink a LED, whose anode is connected to Port0.0 #include<lpc21xx.h> / int main() { int i; PINSEL0=0x00000000; //port 0 set to GPIO IO0DIR=0x00000001; // 0th bit of port 0 will act as o/p while(1) { IO0SET=0x00000001; // LED will glow for(i=0;i<100000;i++); //to create some delay IO0CLR-0x000000001; //Led will off for(i=0;i<100000;i++); //to create some delay

} }
www.embbsys.blogspot.in

How to check Input in ARM7


To check input in ARM, we can use a register named as IOPIN. This register can also be used to set output. Example: if((IO0PIN&0x00000001) = = 0x00000001); { //this statement will execute when the 0th bit of port0 will be high } IO0PIN=0x00000002;// it means 1st bit of Port 0 set to High (As output)

Lets Do a I/P and O/P program


#include<lpc21xx.h> int main() { PINSEL0=0; IO0DIR=0x000000ff; PINSEL2=0x00000000; IO1DIR=0x00000000; if((0x00010000&IO1PIN)==0x00000000) //giving input at p1.16 { IO0PIN=0x00000001; // anode of led is connected to 0th bit of Port0 } else { IO0PIN=0x00000000; } }

Ckt Dig of the above code

You might also like