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

UART LPC2129 Unpredictable result on hardware

Hi,
The following run perfctly on the Keil...But if downloaded on board it dosen't work...I connected the board with PC and Send Values on UART through Hyperterminal...Is their anything I need to Change?

#include <LPC21xx.H> // LPC21xx definitions
#include <stdio.h> char command=0; __irq void Uart_isr(void)
{ command=U0RBR; VICVectAddr=0;
}

void SlowDown (unsigned int delay )// Number of 100us timeouts used for waiting {

unsigned int ii,jj; for(ii=0;ii<=delay;ii++) { for(jj=0;jj<1000;jj++); }
}

int main(void) {

PINSEL0 = PINSEL0 | 0x00000005;

U0LCR = 0x83; /* DLAB=1 8 bits, no Parity, 1 Stop bit */ U0DLL = 97; /* 38400 Baud Rate @ 15MHz VPB Clock */ U0DLM = 0x00; U0LCR = 0x03; /* DLAB=0 */ /* transmit enable */ U0IER=0x01; /* disable all interrupts */ VICVectAddr0=(unsigned int)Uart_isr; VICVectCntl0= 0x20|6; VICIntEnable=1<<6;

while(1)
{ //SlowDown(200); printf("Enter command(x-Request ADC data \nc-Request ADC data at 0.5 Hz \n)::"); //SlowDown(200); U0IER = 0x01;

while(command==0); switch(command) { case 'x': case 'X':

printf("\n Command X\n"); break; case 'c': case 'C': printf("Enter 'T' to terminate the operation:"); while(command=='c' || command=='C') { printf("\n Command C\n"); } break; default: printf("Invalid command detected..."); break;

} command=0;
} }

0