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;
unsigned char buf[16] = {0};

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

}
void DELAY()
{
unsigned int x=1000000;
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()
{

init_serial();

 

 


DELAY();
DELAY();

while(1)
{

DELAY();
ADCR=0x01240001;
while((ADDR&0X80000000)!=0X80000000); //P0.27
adc_value1=(ADDR>>6)&0X000003FF;

adc_value2=adc_value1;
ADCR=0x01240002;
while((ADDR&0X80000000)!=0X80000000); //P0.28
adc_value2=(ADDR>>6)&0X000003FF;


sprintf((char *)buf, "AN0 = %d ", adc_value1);
TRANSMIT_UART1(buf);
sprintf((char *)buf, "AN1 = %d ", adc_value2);
TRANSMIT_UART1(buf);
sendchar(13);
}

}

 

Back to top