PININT on port 2 LPC11U68

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PININT on port 2 LPC11U68

Jump to solution
870 Views
pavelhudecek
Contributor III

Hi,

programming custom board with LPC11U68JBD100.

I initialize PININT on port 0 pins 2 and 20, port 2 pins 2 and 5 using these functions:

 

Chip_GPIO_Init(LPC_GPIO);

Chip_GPIO_SetPinDIRInput(LPC_GPIO, ...

 

Chip_Clock_SetIOCONFiltClockDiv(0, 64);

 

Chip_IOCON_PinMuxSet(LPC_IOCON, ... (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_HYS_EN | IOCON_S_MODE(3))

 

Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);

 

Chip_SYSCTL_SetPinInterrupt(n, ...

Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(n));

(n is 0 to 3)

 

NVIC_ClearPendingIRQ(name);

NVIC_EnableIRQ(name);

(names are PIN_INT0_IRQn to PIN_INT3_IRQn)

 

Created four handlers ( PIN_INT0_IRQHandler() ... PIN_INT3_IRQHandler() )

Handlers execute:

 

Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(int number));

and blink with LEDs.

 

int 0 and 1 (port 0.2 and 0.20) working properly, LEDs blinks after pin pulled low

int 2 and 3 (port 2.2 and 2.5) not working

 

What's wrong?

 

Thanks

Labels (3)
Tags (1)
0 Kudos
1 Solution
547 Views
pavelhudecek
Contributor III

Solved:

My code is OK.

Wrong is function Chip_SYSCTL_SetPinInterrupt

from examples archive lpcopen_2_06_lpcxpresso_nxp_lpcxpresso_11u68.zip

distributed with LPCXpresso v8.1.4_606

lpc_chip_11u6x\src\syscon_11u6x.c

Wrong, original version, working only with port 0:

void Chip_SYSCTL_SetPinInterrupt(uint32_t intno, uint8_t port, uint8_t pin){

if (port == 0) {

       /* Pins P0.1 to P0.23 only */

       LPC_SYSCTL->PINTSEL[intno] = (uint32_t) pin;

} else {

       /* P1.1 to P1.31 and P2.0 to P2.7 */

       LPC_SYSCTL->PINTSEL[intno] = (uint32_t) ((port - 1) * 32 + pin);

}

}

Repaired:

void Chip_SYSCTL_SetPinInterrupt(uint32_t intno, uint8_t port, uint8_t pin){

if (port == 0) {

  // Pins P0.0 to P0.23 only

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) pin;

} else if (port == 1) {

  // P1.0 to P1.31

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) (24 + pin);

} else {

  // P2.0 to P2.7

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) (24+32 + pin);

}

}

View solution in original post

0 Kudos
1 Reply
548 Views
pavelhudecek
Contributor III

Solved:

My code is OK.

Wrong is function Chip_SYSCTL_SetPinInterrupt

from examples archive lpcopen_2_06_lpcxpresso_nxp_lpcxpresso_11u68.zip

distributed with LPCXpresso v8.1.4_606

lpc_chip_11u6x\src\syscon_11u6x.c

Wrong, original version, working only with port 0:

void Chip_SYSCTL_SetPinInterrupt(uint32_t intno, uint8_t port, uint8_t pin){

if (port == 0) {

       /* Pins P0.1 to P0.23 only */

       LPC_SYSCTL->PINTSEL[intno] = (uint32_t) pin;

} else {

       /* P1.1 to P1.31 and P2.0 to P2.7 */

       LPC_SYSCTL->PINTSEL[intno] = (uint32_t) ((port - 1) * 32 + pin);

}

}

Repaired:

void Chip_SYSCTL_SetPinInterrupt(uint32_t intno, uint8_t port, uint8_t pin){

if (port == 0) {

  // Pins P0.0 to P0.23 only

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) pin;

} else if (port == 1) {

  // P1.0 to P1.31

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) (24 + pin);

} else {

  // P2.0 to P2.7

  LPC_SYSCTL->PINTSEL[intno] = (uint32_t) (24+32 + pin);

}

}

0 Kudos