help about interrupt uc/os 2.91 lpc1768

help about interrupt uc/os 2.91 lpc1768

Home Forums Example Projects help about interrupt uc/os 2.91 lpc1768

This topic contains 3 replies, has 2 voices, and was last updated by  amintanharpd@yahoo.com 5 days, 15 hours ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25384

    hi , how can i use external interrupt in lpc1768 with uC/os, i used regular code for interrupt
    void EINTInit( void )
    {
    LPC_PINCON->PINSEL4 = 0x01000000;
    LPC_GPIO2->FIODIR &=0xffffefff;
    LPC_GPIOINT->IO2IntEnF = 0x1000;
    LPC_SC->EXTMODE = 0x00000000;
    LPC_SC->EXTPOLAR = 0;
    NVIC_EnableIRQ(EINT2_IRQn);
    return;
    }
    and my interrupt handler this:

    void EINT2_IRQHandler (void)
    {

    LPC_GPIOINT->IO2IntClr |= (1 << 12);
    UART_PrintStr(“hello”);
    return;
    }
    but when i use this code and when active interrupt , OS go to halt , and stop working , my question is that how can i use interrupt in uC/OS? i tried with
    CPU_SR_ALLOC();
    CPU_CRITICAL_ENTER();
    OS_ENTER_CRITICAL();
    OS_EXIT_CRITICAL();
    ….
    and like this instruction but don’t work for me , do anybody know about interrupt uC/OS in LPC1768 that exactly what i do?
    (sorry for language)

    #25401

    i could solve my problem but appeared 1 problem , my code this :

    static void App_TaskStart (void *p_arg)
    {

    int ch_nbr;

    /* enable interrupt with register and 2 function for uC/OS */
    LPC_PINCON->PINSEL4 = 0x01000000;
    LPC_GPIO2->FIODIR &=0xffffefff;
    LPC_GPIOINT->IO2IntEnF = 0x1000; /* Port2.12 is falling edge. */
    LPC_SC->EXTMODE = 0x00000000; /* INT2 edge trigger */
    LPC_SC->EXTPOLAR = 0;
    CSP_IntEn (CSP_INT_CTRL_NBR_MAIN,CSP_INT_SRC_NBR_EINT_02);
    CSP_IntVectReg((CSP_DEV_NBR )CSP_INT_CTRL_NBR_MAIN,
    (CSP_DEV_NBR )CSP_INT_SRC_NBR_EINT_02,
    (CPU_FNCT_PTR )App_Ext2_IntHandler,(void *)ch_nbr);
    CPU_IntSrcDis(SystemCoreClock/1000);
    /* start first task*/
    App_TaskCreate(); /* Create Application tasks */
    for(;;)
    {

    OSTimeDlyHMSM(0, 1, 0, 0);
    }

    }

    then this is my handler interrupt:

    void App_Ext2_IntHandler (void *p_arg)
    {

    CSP_GPIO_IntClr(CSP_GPIO_PORT_NBR_02); /* Clear external interrupt on Port 2. */

    UART_PrintStr(“hello”);

    CSP_IntDis(CSP_INT_CTRL_NBR_MAIN, /* Disable external Interrupt.*/
    CSP_INT_SRC_NBR_EINT_02);

    CPU_IntSrcEn(SystemCoreClock/1000);

    return ;
    }

    and interrupt is ok but now i have a problem that this interrupt run just for 1 time and disable for ever if i enable again interrupt on another task system go to halt(stop) , so now what can i do for resolving problem?
    how can i enable interrupt again?

    #25411

    Fernando Flores
    Keymaster

    * if you are trying to Enable/Disable interrupts. Use CSP_IntEn()/CSP_IntDis()
    * CPU_IntSrcDis(SystemCoreClock/1000); —-> this is completely incorrect use CSP_IntDis (CSP_INT_CTRL_NBR_MAIN,CSP_INT_SRC_NBR_EINT_02);

    * CPU_IntSrcEn(SystemCoreClock/1000);—–> use CSP_IntEn (CSP_INT_CTRL_NBR_MAIN,CSP_INT_SRC_NBR_EINT_02);

    * UART_PrintStr(“hello”); —-> Remove this code from your ISR for now and try to increment a global variable to see if you get the same results.

    * Keep in mind that Micrium no longer supports CSP package.

    #25461

    my first code was right and my problem was for another part of code not interrupt, my interrupt routine is right and now working good 😉
    thank you for answering

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

View the complete site map

x
Loading...