Connect with us

UART interrupt LPC2148

Discussion in 'Microcontrollers, Programming and IoT' started by sid2286, May 21, 2014.

  1. sid2286

    sid2286

    102
    1
    Aug 24, 2011
    Hi,

    I am trying to generate an uart0 interrupt, wrote a piece of code, not sure what is wrong.
    the code is as follows:

    #include <LPC214x.H> //LPC214x definition

    #define Fosc 12000000
    #define Fcclk (Fosc * 5)
    #define Fcco (Fcclk * 4)
    #define Fpclk (Fcclk / 4) * 1
    #define UART_BPS 9600 //Set Baud Rate here

    #define LED1_ON() IO1SET=(1<<16) //Macro Functions to turn ON LED
    #define LED2_ON() IO1SET=(1<<17)
    #define LED3_ON() IO1SET=(1<<18)
    #define LED4_ON() IO1SET=(1<<19)

    #define LED1_OFF() IO1CLR=(1<<16) //Macro Functions to turn OFF LED
    #define LED2_OFF() IO1CLR=(1<<17)
    #define LED3_OFF() IO1CLR=(1<<18)
    #define LED4_OFF() IO1CLR=(1<<19)

    __irq void myUart0_ISR(void)
    {
    //static int i=0;
    LED1_ON();
    //i++;
    VICVectAddr = 0x00;
    }


    void Init_UART0(void) //This function setups UART0
    {
    unsigned int Baud16;
    U0LCR = 0x83; // DLAB = 1
    Baud16 = (Fpclk / 16) / UART_BPS;
    U0DLM = Baud16 / 256;
    U0DLL = Baud16 % 256;
    U0LCR = 0x03;
    }
    void init_intt_uart0()
    {
    U0FCR |= 0x01; //FIFO
    VICIntEnable |= (1<<6) ;
    VICVectCntl0 = (1<<5) | 6 ;
    VICVectAddr0 = (unsigned) myUart0_ISR;
    U0IER |= 0x01;
    }

    void Delay_Ticks(unsigned int Delay) //Function to generate finite delay
    {
    unsigned int i;
    for(; Delay>0; Delay--)
    for(i=0; i<50000; i++);
    }


    int main(void)
    {
    PINSEL0 = 0x00050005; // Enable UART1 UART0 Rx and Tx pins
    PINSEL1 = 0x00000000;
    PINSEL2 = 0x00000000;
    Init_UART0();
    init_intt_uart0();
    IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16); //led PINS OUTPUT ASSIGNED

    while(1)
    {
    LED3_ON();
    Delay_Ticks(100);
    LED4_ON();
    Delay_Ticks(100);
    LED3_OFF();
    Delay_Ticks(100);
    LED4_OFF();
    Delay_Ticks(100);
    }
    return(0);

    }


    the interrupt is occuring but then its not coming out of ISR.


    please help.
    Sid
     
  2. er.gaurav.info

    er.gaurav.info

    1
    0
    Jul 4, 2015
    buddy thanks i got ur problem and my solution tooo........
    __irq void myUart0_ISR(void)
    {
    //static int i=0;
    LED1_ON();
    //i++;
    VICVectAddr = 0x00; //should be VICVectAddr0 = 0x00;
    }
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-