Bad Interrupt

Why my interrupt is not working ?
It is behaving like disabled

my new version.txt (1.78 KB)

Hrishikale89:
Why my interrupt is not working ?
It is behaving like disabled

You forgot to tell us what it connected to the interrupt pin you are using. I'll assume, then, that that thing is not generating any changes that trigger your interrupt handler.

Why are you turning interrupts off and on?

@Hrishikale89,
Why are you hijacking an old thread?

Thread split.

Post your code in code tags NOT as an attachment and make sure that you use auto format before posting

Mark

Hrishikale89:
Why my interrupt is not working ?
It is behaving like disabled

What is your program trying to do. It looks like a very strange use of an interrupt.

...R

Interrupt channel 3 doesn't exist on the Uno, there's only 0 and 1.

Using LOW rather than RISING, FALLING or CHANGE is usually a mistake.

Your code would be readable if each motor action was in a well-named function of its own, like

void leftmotor (boolean on)
{
....
}

MarkT:
Using LOW rather than RISING, FALLING or CHANGE is usually a mistake.

The above quote does not agree with what the datasheet says -- active LOW can always be chosen as the trigger level for the interrupting signal?

active LOW can always be chosen as the trigger level for the interrupting signal?

Yes, but it doesn't always (or even usually) make sense to do that.

Suppose that you have the internal pullup resistor active on the interrupt pin. The pin will be held HIGH until the external source pulls it LOW.

Now, that is not what an external source usually does. Usually, the external source holds the pin LOW, and pulls it HIGH to trigger the interrupt. So, LOW triggering the interrupt handler would not be what you want. The ISR would be dominating the program.

active LOW can always be chosen as the trigger level for the interrupting signal?

If the interrupt pin is held LOW do you really want the ISR to be triggered over and over again ?

UKHeliBob:
If the interrupt pin is held LOW do you really want the ISR to be triggered over and over again ?

The problem that you are suspecting to happen could always be avoided by the following arrangement where the interrupting signal uses an one-shot and produces a narrow active-low pulse of 100 us width to interrupt the MCU.

The problem that you are suspecting to happen could always be avoided by the following arrangement

It could more easily be accomplished by using the correct trigger type. LOW is rarely the proper trigger type.

The problem that you are suspecting to happen could always be avoided by the following arrangement where the interrupting signal uses an one-shot and produces a narrow active-low pulse of 100 us width to interrupt the MCU.

Why complicate things by adding hardware when the problem is easily avoided in software ?

UKHeliBob:
Why complicate things by adding hardware when the problem is easily avoided in software ?

Because someone likes to overcomplicate things, or it makes a longer enumeration list? :wink:

Whandall:
Because someone likes to overcomplicate things, or it makes a longer enumeration list? :wink:

Is it over-complication or necessity -- the answer is with the instrument designer?

Assume that irregularly-spaced pulses are coming from the tachometer/transducer of a Taximeter. These pulses are to be given regular shapes for which the one-shot is the good choice. The user intentionally wishes to use the Active Low state of the pulse as the triggering level for the interrupt. Why is it not the RE or FE? This is to avoid the possible detection of the noise signal which just occurs momentarily as an edge. Thanks to the ATmega328P Designer Group for incorporating the Low Level triggering feature in the interrupt logic of the MCU.

GolamMostafa:
The user intentionally wishes to use the Active Low state of the pulse as the triggering level for the interrupt.

Using LOW rather than FALLING is an absolute crap idea that only works when adding external components,
or going through rather complicated steps to disable it in the instant it is asserted
and enabling it again after polling the signal for having returned to HIGH.

You can copy some chapters from wherever now, but it will only obfuscate, not change facts.