caio reia

problem lwgpio isr M52233demo board

Discussion created by caio reia on Sep 18, 2014
Latest reply on Sep 22, 2014 by caio reia

Hi everyone,

 

I’m having a problem setting the irq7 int on M52233demo board. It just doesn’t enter the callback function and curiously don’t open BSP_SW2 port !!

It doesn’t get to callback function and doesn’t get LWGPIO_VALUE_LOW value.

Here comes the odd thing.

When I comment the "lwgpio_set_functionality statement" it prints “..pin7 – low – sw2=pressed..” when button pressed, but dont enter callback.

However the most strange thing is that when I change the statement “status = lwgpio_init(&IntPort,BSP_SW1, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE); from BSP_SW1 to BSP_SW2”  I get printf("Initialising GPIO as input failed.\n");  that is, it doesn’t open the SW2 port while it opens SW1 port !!

I’m lost.  Tried lots of variations of this code.

My user define since it has other projects closed for this test, contain defines set to SPI, ADC, TCP/IP, SNMP, TIMER. I’m not quite sure if it makes any difference for this test.

Any help would be great.

 

The code is as follows:

void IntCallback(void* data)
{
        lwgpio_int_clear_flag((LWGPIO_STRUCT_PTR)data);
        
        printf ("..interrup port entered..");

}

/*TASK*-------------------------------------------------------------------

*

* Task Name : main_task

* Comments  :

*

*END*----------------------------------------------------------------------*/

void main_task

   (

      uint_32 dummy

   )

{

        MQX_FILE_PTR mySpiFd;  //not used now

        LWGPIO_STRUCT IntPort;

        boolean status;

        uint_32 vector;

       

        status = lwgpio_init(&IntPort,BSP_SW1, LWGPIO_DIR_INPUT, LWGPIO_VALUE_NOCHANGE);

        lwgpio_set_functionality(&IntPort, LWGPIO_MUX_NQ7_GPIO);     //BSP_SW1_MUX_IRQ);//

        lwgpio_set_attribute(&IntPort, LWGPIO_ATTR_PULL_UP, LWGPIO_AVAL_ENABLE);

              

        if (status != TRUE) {

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

               //_mqx_exit(-1);

        }else

               status = lwgpio_int_init(&IntPort, LWGPIO_INT_MODE_FALLING);

       

        if (status != TRUE) {

               printf("Initialising pin for interrupt failed.\n");

               //_mqx_exit(-1);

        }

       

        vector = lwgpio_int_get_vector(&IntPort);

        if (NULL == (_int_install_isr(vector, IntCallback, (void *) &IntPort) ) )

                       printf ("..error setting isr callback..");

        //_bsp_int_init(vector, 3, 0, TRUE); 

       

        lwgpio_int_clear_flag(&IntPort);

        lwgpio_int_enable(&IntPort, TRUE);

       

  

   while ( 1 ) {

          

           if ( LWGPIO_VALUE_LOW == lwgpio_get_raw(&IntPort) ) {

                  printf (" ..pin7 - low - sw2=pressed..");

           }

}

}

Outcomes