+ Post New Thread
Results 1 to 1 of 1
  1. #1
    Newbie level 4
    Points: 203, Level: 2

    Join Date
    Mar 2013
    Posts
    5
    Helped
    0 / 0
    Points
    203
    Level
    2

    Code for UART with interrupt for LPC2138

    Hello everyone,

    I need a code for LPC2138 to run UART with interrupt. I have pasted my code below. I am switching on an LED inside the interrupt if '1' is received. But the led constantly stays on and that too its dim with a voltage of 3.3V across it. Please help!!

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    #include<lpc21xx.h>
    __irq void UART0_ISR(void);
    int main()
    {
        PINSEL0 = 0x05;
        U0LCR = 0x83;
        U0DLL = 124;
        U0LCR = 0x03;
        U0IER = 0x01;
        IODIR0 = 0x00000010;
        IOCLR0 = 0x00000010;
        VICVectAddr0 = (unsigned int)UART0_ISR;
        VICVectCntl0 =  0x20|6;
        VICIntEnable = 0x00000040;
        while(1)
        {
        }
    }
    __irq void UART0_ISR(void)
    {
        if((U0IIR & 0x04)==0x04)
        {
            if(U0RBR == '1')
                IOSET0 = 0x00000010;
            else
            IOCLR0 = 0x00000010;
        }
        VICVectAddr = 0;
    }
    Last edited by andre_teprom; 23rd January 2014 at 21:49. Reason: syntax formatting

    •   Alt23rd January 2014, 18:37

      advertising

        
       

--[[ ]]--