Author Topic: How to add minimum time width Rising Edge interrupt Mega2560  (Read 648 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 488
How to add minimum time width Rising Edge interrupt Mega2560
« on: December 05, 2017, 05:47:53 am »
1. I am using atmega2560 & configured rising edge interrupt by below code. Normally pulse is low, & it gives a pulse of minimum 10ms whenever event occurs. Have to reject any rising edge if pulse width is less than 10ms.

const byte interruptPin = 2;

void setup()
{
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), isr_func, RISING);
}


2. Is there any arduino function for it? Or how to do it arduino?
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: How to add minimum time width Rising Edge interrupt Mega2560
« Reply #1 on: December 05, 2017, 06:16:48 am »
Instead of RISING use CHANGE. Inside the ISR you can determine if it's rising or falling by reading the pin. If the fall came less than 10 ms after the rise you can reject the pulse. You'll also need something in your main loop or on a timer interrupt to determine when the pulse is to be accepted.

Not the only way, but the one that jumps to mind.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf