AnsweredAssumed Answered

lwgpio interrupt problem

Question asked by He Yunfei on Apr 21, 2014
Latest reply on May 12, 2014 by Carlos_Musich

I run the gpio demo based on mqx4.1.it is successful.

I copy the demo to my project, and the result is changed.

the result of the demo is : when I press the button ,it enter the ISR,

but

the restult of my project: when after calling _bsp_int_init(lwgpio_int_get_vector(&btn1), 3, 0, TRUE),  it enter the ISR Automatically,  then I press the button, it enter the isr.

when I modify the priority  _bsp_int_init(lwgpio_int_get_vector(&btn1), 3, 0, TRUE) :3 --->8

then it can't enter the isr forever.

 

my project  is :

void int_service_routine10(void *pin)

{

 

    lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR) pin);

}

void main_task1

    (

        uint32_t initial_data

    )

{

    LWGPIO_STRUCT led1, btn1;

 

    _mqx_uint result;

   

    if (!lwgpio_init(&btn1, (GPIO_PORT_B | GPIO_PIN5), LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE))//(GPIO_PORT_B | GPIO_PIN4)(GPIO_PORT_B | GPIO_PIN7)

    {

        printf("Initializing button GPIO as input failed.\n");

        _task_block();

    }

    lwgpio_set_functionality(&btn1, 1);

 

  lwgpio_set_attribute(&btn1, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);

  

    if (!lwgpio_int_init(&btn1, LWGPIO_INT_MODE_FALLING))

    {

        printf("Initializing button GPIO for interrupt failed.\n");

        _task_block();

    }

     _int_install_isr(lwgpio_int_get_vector(&btn1), int_service_routine10, (void *) &btn1);

    lwgpio_int_clear_flag(&btn1);

    lwgpio_int_enable(&btn1, TRUE);

  _bsp_int_init(lwgpio_int_get_vector(&btn1), 3, 0, TRUE);

    button_press_count = 1;

    while(button_press_count < 4)       {

        printf("Button pressed %dx\r", button_press_count);

    }

 

    lwgpio_int_enable(&btn1, FALSE);

}

void main_task(uint32_t initial_data)

{

     main_task1(1);

}

Outcomes