Facing problem with external interrupt3 of lpc1769

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by sanita on Mon Jan 18 21:52:41 MST 2016

I developed an application to generate the pulses(pwm) using timer of lpc1769. The period of pulse is 10milli seconds and pulse width can be varied as required. The pulse width is generated depending on the reference signal which is a square wave of 10milli seconds(with on period of 7.2ms and off period of 2.8ms). whenever there is rising edge of this signal PWM pulse should start. Now this is working fine. To detect the rising edge i used GPIO interrupt with external interrupt3 the ISR is as :
1) if rising edge on GPIO pin(P2.11)
2) Clear the rising edge status on the pin.
3) then set the timer for few milli seconds

and in timer ISR
1) Clear any pending Timer IRQs
2)Make the GPIO pin high on which generating PWM pulse(P2.6)
3) set the timer for few milli seconds and then clear the pin(P2.6)(same timer is used in both the ISRs)
4) Disabling the timer and re enabling the rising edge interrupt on GPIO pin(P2.11), so again serves the ISR of external interrupt3 on rising edge of reference signal and it continues as above.

Now i am getting the problem in the code in developing the application as,
1) if rising edge disable the interrupt and set timer to 8 milli seconds delay.
2) In timer ISR generate 10 pwm cycles after this re enable the external interrupt. (the same timer is used in both ISRs)
3) so my output should be with respect to rising edge of reference signal 8 milli second delay then 10 pwm cycles(all have time period of 10ms) again 8ms delay with respect to rising edge of reference signal and 10 pwm cycles.

But once after 10 cycles when i re enable the external interrupt irrespective of rising edge of reference signal a delay of 8ms is added.
whenever last 10th cycle is complete I am enabling the interrupt again, so from this point only it adding a 8ms delay. My question is if interrupt is enabled for rising edge of reference signal then it should serve ISR for rising edge only. But this is not happening in this case. I am not understanding this behaviour.
This is my code, this is ISR for external interrupt3



uint32_t i;
        if(((Chip_GPIOINT_GetStatusRising(LPC_GPIOINT, GPIO_INTERRUPT1_PORT) >> GPIO_INTERRUPT1_PIN) & 0x01) != 0) /*Group 1*/


count1 = 0;

start_timer1((HALF_WAVE_PERIOD - DELAY) * timerTick);




Timer1 ISR is

void TIMER1_IRQHandler(void)


if (Chip_TIMER_MatchPending(LPC_TIMER1, 1) == 0)




Chip_TIMER_ClearMatch(LPC_TIMER1, 1);

if(count1 > 10)


LPC_GPIO1->PIN = (LPC_GPIO1->PIN & ~(1 << 19));






case 1:

state1 = 2;

LPC_GPIO1->PIN = (LPC_GPIO1->PIN | (1 << 19));
set_timer1(2000 * timerTick);


case 2:

state1 = 1;

                                LPC_GPIO1->PIN = (LPC_GPIO1->PIN & ~(1 << 19));

set_timer1((HALF_WAVE_PERIOD - DELAY) * timerTick);







HALF_WAVE_PERIOD = 10000 microseconds
DELAY = 2800 microseconds

and functions start_timer1 is used to initialize the timer1 and set the timer1 for given number of ticks and interrupt on match.
set_timer1 : set timer1 for given ticks and interrupt.
stop_timer1 : disable the timer1 and enables the external interrupt3.

Please reply