This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2148 Pin Data fetching issue

I want to get the count whenever a pin gets high and store it in a variable and then use every count of the variable in if loop for my process. 

What would be the syntax and how can i add a counter if i am using just a pin suppose P0.15 of LPC2148. 

can anyone help me with a small guiding syntax to how to incorporate a counting variable for a pin to count no of time the pin gets high and if the pin gets high after a particular value suppose 4 i want to reset the count.

Parents Reply Children
  • "The " Count whenever a pin gets high .. I want a variable to count the number of times a Pin gets High and i want to use that count for further loops.

  • Configure EINT2 to use pin P0.15 as its interrupt source.  Configure the logic on EINT2 properly (probably edge / High, but possibly level / High)

    Write an interrupt handler for the EINT2 interrupt.  Increment a count variable in the interrupt handler.

    Enable the EINT2 interrupt.

    Be careful, buttons tend to bounce so you may get "many" interrupts when you really think you should only get 1.  You may need to debounce the pin some how.