Toll-Free Customer Support 24/7

ARM Development Board-LPC2129

/*
* Project name:
ARM Development Board-LPC2129
* Copyright
(c) Researchdesignlab.com
* Description:

* Test configuration:
MCU: LPC2129
Dev.Board: LPC2129 mini
Oscillator: 12 MHz
Software: Keil uVision4

*/

#include<stdio.h>
#include"lpc21xx.h" // header file
#include<string.h>


unsigned int adc_value1,adc_value2,C;
unsigned char buf[16] = {0};
char check_key(void);
unsigned int KeyPort=0X007FF000;

#define sw1 0x00008000
#define sw2 0x00010000
#define sw3 0x00020000
#define sw4 0x00040000

void TRANSMIT_UART1(unsigned char *P)
{
while(*P){
U1THR=*P;
while(!(U1LSR&0X20));
P++;}

}
void DELAY()
{
unsigned int x=100;
while(x--) ;

}

void init_serial (void) { /* Initialize Serial Interface */
PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U1LCR = 0x03; /* DLAB = 0 */
}

void sendchar (int ch) { /* Write character to Serial Port */

U1THR=ch;
while(!(U1LSR&0X20));
}

int main()
{


// IODIR0=0X0007ffCF0;
IODIR0=KeyPort;
init_serial();
DELAY();
DELAY();
TRANSMIT_UART1("Researchdesignlab.com");
sendchar(10);
sendchar(13);

while(1)
{

DELAY();
sendchar(check_key());
}

}


char check_key(void)
{

while(1)
{
//

IOSET0=0x00778000;
DELAY();
if((IOPIN0&sw1)==0)
{
C='0';
// while((IOPIN0&sw1)==0);
return(C);

}
if((IOPIN0&sw2)==0)
{
C='1';
// while((IOPIN0&sw2)==0);
return(C);
}
if((IOPIN0&sw3)==0)
{

C='2';
// while((IOPIN0&sw3)==0);
return(C);

}
if((IOPIN0&sw4)==0)
{
C='3';
// while((IOPIN0&sw4)==0);
return(C);

}

IOCLR0=0x00778000;
DELAY();

IOSET0=0x006f8000;

DELAY();
if((IOPIN0&sw1)==0)
{
C='4';
// while((IOPIN0&sw1)==0);
return(C);

}
if((IOPIN0&sw2)==0)
{
C='5';
// while((IOPIN0&sw2)==0);
return(C);

}
if((IOPIN0&sw3)==0)
{
C='6';
// while((IOPIN0&sw3)==0);
return(C);

}
if((IOPIN0&sw4)==0)
{
C='7';
// while((IOPIN0&sw4)==0);
return(C);

}


IOCLR0=0x006f8000;
DELAY();



IOSET0=0x005F8000;

DELAY();
if((IOPIN0&sw1)==0)
{
C='8';
// while((IOPIN0&sw1)==0);
return(C);

}
if((IOPIN0&sw2)==0)
{
C='9';
// while((IOPIN0&sw2)==0);
return(C);

}
if((IOPIN0&sw3)==0)
{
C='A';
// while((IOPIN0&sw3)==0);
return(C);
}
if((IOPIN0&sw4)==0)
{
C='B';
/// while((IOPIN0&sw4)==0);
return(C);
}
IOCLR0=0x005f8000;

DELAY();

IOSET0=0x003F8000;

DELAY();
if((IOPIN0&sw1)==0)
{
C='C';
// while((IOPIN0&sw1)==0);
return(C);

}
if((IOPIN0&sw2)==0)
{
C='D';
// while((IOPIN0&sw2)==0);
return(C);
}
if((IOPIN0&sw3)==0)
{
C='E';
// while((IOPIN0&sw3)==0);
return(C);
}
if((IOPIN0&sw4)==0)
{
C='F';
// while((IOPIN0&sw4)==0);
return(C);
}

IOCLR0=0x003F8000;
DELAY();


}

}

 

Back to top