LPC2103 UART0 Interrupt

Status
Not open for further replies.

AtomSoft

Well-Known Member
Ok im having some trouble but not where you would think...

I want to use interrupt to capture incoming UART data. The issue is the data isnt correct.

Code:
void InitPLL(void)
{
  PLLCFG=0x44;

  PLLCON=0x1;
  PLLFEED=0xAA;
  PLLFEED=0x55;
  APBDIV = 0x01;

  while(!(PLLSTAT & 0x400)){}  ;

  PLLCON=0x3;
  PLLFEED=0xAA;
  PLLFEED=0x55;
}

void Init_UART (void)
{
    int Div;

    /* Initialize Pin Select Block for Tx and Rx */
    PINSEL0=0x5;
    /* Enable FIFO's and reset them */
    U0FCR=0x7;
    /* Set DLAB and word length set to 8bits */
    U0LCR = 0x83;
    /* Baud rate set to 19200 */
    Div = (60000000/16)/19200;
    U0DLM = Div/256;
    U0DLL = Div %256;
     /* Clear DLAB */
    U0LCR = 0x03;

    U0IER = 0x03; //RDA 
    //Interrupt Setup
    VICIntEnClr     = 0xFFFFFFFF; //Disable all interrupts
    VICIntSelect = 0x00; //UART0 = IRQ Interrupt
    VICVectCntl0 = 0x26; // Vector 0 is for UART0 and is Enabled
    VICVectAddr0 = (unsigned long)UART0_ISR; //Prototype address to be called 
    VICIntEnable = 0x40; //Enable UART0 Interrupt       
}
void UART0_ISR(void) 
{
    unsigned char temp = U0RBR;

    VICSoftIntClear = 0x40; //Clear Interrupt
    VICVectAddr=0xFF;
}

example 1: if i send a 0x31(aka 1 key) to the MCU it shows 0x99 as the input.
example 2: if i send a 0x32(aka 2 key) to the MCU it shows 0x9A as the input.

What can be wrong ?

MCU is running at 60Mhz, BAUD RATE is 19200. Help Please.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…