Arduino Forum

Using Arduino => General Electronics => Topic started by: devigan on Oct 14, 2020, 10:04 am

Title: Random interrupt
Post by: devigan on Oct 14, 2020, 10:04 am
Am using a MC14490 debounce eliminators'  for switch press. And the switch press trigger  external interrupt. The program works fine but there is random interrupt trigger ,during power on.

Code:
int MyPin = 6 ;
int Led =13;
volatile int State = 1;

void setup() {
pinMode(Led, OUTPUT);
attachInterrupt(digitalPinToInterrupt(MyPin), Blink, CHANGE);
}
void loop() {
digitalWrite(Led, State); // turn the LED on (HIGH is the voltage level)
}
void Blink () {
State = !State;
}

I assume the debounce would eliminatior would take care of noise trigger . I assume wrong. Any suggestions
Title: Re: Random interrupt
Post by: ShermanP on Oct 14, 2020, 04:57 pm
I suggest you clear the interrrupt flag register that applies to the pin 6 external interrupt before you attach the interrupt to it in Setup().  You'll have to check the datasheet for how to do that.  And it wouldn't hurt to excute the same command as part of the ISR (although that may happen automatically for external interrupts - I don't remember).

Also, do  you intend that the state should change when the button is pressed and when it is released?  In other words, do you want CHANGE or just FALLING?
Title: Re: Random interrupt
Post by: Klaus_K on Oct 15, 2020, 03:35 am
According to the MC14490 datasheet page 1

"NOTE: Immediately after powerup, the outputs of the MC14490 are in indeterminate states."

Sounds like an invitation for random interrupt signals at start-up.

I am curious, why do you use the MC14490 instead of using software?