LPC4337, gpio_irq_api.c: InterruptIn pin assignment bug

08 Jan 2016

During a project at school, we ran into a problems with the interrupt pins on the LPCXpresso4337. We have discovered a bug in the gpio_irq_api.c file and modified the code. Code was tested on LPCXpresso4337.

OLD:

gpio_irq_api.c OLD

    /* Set SCU */
    if (channel < 4) {
          LPC_SCU->PINTSEL0 &= ~(0xFF << (portnum << 3));
          LPC_SCU->PINTSEL0 |= (((portnum << 5) | pinnum) << (channel << 3));
    } else {
          LPC_SCU->PINTSEL1 &= ~(0xFF << ((portnum - 4) << 3));
          LPC_SCU->PINTSEL1 |= (((portnum << 5) | pinnum) << ((channel - 4) << 3));
    }

SUGGESTION:

gpio_irq_api.c SUGGESTION

    /* Set SCU */
    if (channel < 4) {
        LPC_SCU->PINTSEL0 &= ~(0xFF << (channel << 3));
        LPC_SCU->PINTSEL0 |= (((portnum << 5) | pinnum) << (channel << 3));
    } else {
        LPC_SCU->PINTSEL1 &= ~(0xFF << ((channel - 4) << 3));
        LPC_SCU->PINTSEL1 |= (((portnum << 5) | pinnum) << ((channel - 4) << 3));
    }
  • "portnum" in line 3 & 6 changed in "channel"
01 Mar 2016

Jasper,

Can you please clarify which pins on which header this affects so we can duplicate the issue and fix?

Alternatively if you would like to submit a fix to the master repo please submit a pull request to www.github.com/mbedmicro/mbed .

Thanks for pointing this out and helping us build awesome!

-Austin

01 Mar 2016

Jasper,

Thank you for reporting this! I have raised this as an issue to get this fixed. For what its worth I just tested your fix and it only enables interrupts on D0-D7, no other pins gain interrupt capability.

-Austin