Interrupt Counter for lpc1114

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

Interrupt Counter for lpc1114

226 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by thomaswin on Thu Oct 20 02:25:48 MST 2011
Hi
I have problem on counting pulse using interrupt from lpc1114.
I using gpio2 counter.i use p2.1 for input and p3.3 for out put.
Do i need to  change setting on timer32.c/gpio.c/IRQ-Handler?
My main program is as below.

#include "LPC11xx.h"                        /* LPC11xx definitions */
#include "clkconfig.h"
#include "gpio.h"
#include "config.h"
#include "timer32.h"


volatile uint32_t gpio2_counter = 0;
/* Main Program */

int main(void) {
    init_timer32(0, TIME_INTERVAL);
    enable_timer32(0);
    GPIOInit();
    GPIOSetDir(3, 3, 1);//led out
    GPIOSetInterrupt( 2, 1, 0, 0, 0 );
    GPIOIntEnable( 2, 1 );
    GPIOSetValue(3, 3, 0);//starting off

   while (1) /* Loop forever */
    {

    if(gpio2_counter <20&& gpio2_counter  >10)//8 count pulse to lpc
              {
                  GPIOSetValue(3, 3, 1);

              }
    if(gpio2_counter <30&& gpio2_counter  >20)// 16 count pulse to lpc
              {
                  GPIOSetValue(3, 3, 0);
              }
if(    gpio2_counter  >30)
        gpio2_counter=0;
    /* Go to sleep to save power between timer interrupts */
        __WFI();

    }
}
0 Kudos
0 Replies