This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM LPC2129..how to assign port pin as input pin

Dear sir,

herewith i attach my program for your reference, if any one knows the solutions plz kindly provides some help for me.

My programs is to assign LPC2129 Port P1's any of the pin is input, when the pin is high, it gives beep sound, otherwise sends character 'A' to serial port.

my doubt is how to assign port1 as input pin,

Program
-------
#include <LPC21XX.H>

unsigned int delay;

void init_serial (void);
void delay1(void);
void alert(void);

//Delay Routine
//---------------------
void delay1(void)
{

for(delay = 0;delay<0xA0000;delay++)//simple delay loop

{;}

}

//Alert Function
//---------------------
void alert(void)
{

IOSET1 = 0x00010000;

delay1();

IOCLR1 = 0x00010000;

delay1();

}

//Initialize serial
//---------------------
void init_serial (void)
{

PINSEL0 = 0x00050000; /* Enable RXD1 TxD1 */

U1LCR = 0x00000083; /*8 bits, 1 Stop bit */

U1DLL = 0x000000C2; /*9600 Baud Rate @12MHz VPB Clock */

U1LCR = 0x00000003; /* DLAB=0*/

}

//Main program starts
//---------------------
int main (void)
{

PINSEL0 = 0;

PINSEL1 = 0;

PINSEL2 &= 0x0000000C;

VPBDIV = 0x02; //Divide Pclk by two

IODIR1 = 0x00000000; // set all pin to input

init_serial();

while (1)

{

if(IOSET1==0X02000000) //check P1.25 is high

alert(); //call alert function

else

U1THR = 'A'; //send 'A' char to serial port

}
}

0