avr external interrupt false trigger -


I was programming for external interrupts using the ATmega 128. I divided the outer interval between 0 and 1, which triggered the rising edge. Calculate the number of times the switch is pressed in between. But when the key is pressed once, the interval is called 2 or 3 times and therefore it means more. What's the problem here?

My interrupt code is here

  ISR (INT1_vect) {cli (); ++ push_cntr1; Printf ("p1:% d", push_cntr1); Sei (); } ISR (INT0_vect) {cli (); ++ push_cntr0; Printf ("p0:% d", push_cntr0); Sei (); } Zero interrupt_init (zero) // enabled between 0 and 1 enabled. {EICRA | = (1 & lt; iSC01) | (0  & lt; ISC00). (1 & lt; ISC11) | (0 > ISC10); EIFR = 0x FF; EIMSC | = (1 & lt; INT1) | (1 & lt; & lt; INT0); DDRD = 0x00; } Int main (zero) // main program {dev_init (); While (1) {process (); } Return 0; }    

I need to clean and set up a little bit inside the handler is . It will be kept in mind by the compiler.

For many hits, you may be suffering from "switch bounce". There are many references to this on the web, but this means that the voltage in the switch circuit is not in a clean jump from 0 to the maximum. This is most often due to the actual physical flood of electrical contacts.

There are several techniques available to "debug" a switch. As you can see TCNT recording and ignoring the interrupt soon after the last one Can try a few simple ones.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -