M
M
MaxEpt2017-11-23 22:05:18
C++ / C#
MaxEpt, 2017-11-23 22:05:18

Why are interrupt counts incorrect in atmega 2560?

Good day to all ! a. I connect the bill receiver to the atmega 2560. I took this article as a basis cxem.net/arduino/arduino136.php 1 impulse - 10 rubles. Why do glitches happen? for example put 100r - will count correctly. Then another 100r (with or without a delay, it doesn’t matter), it can count as 120r, or as 90 ((
Interrupt initialization:

void init_interrupt(){
  EICRA &= ~(1<<ISC00);
  EICRA |= (1<<ISC01);
  
  /*EICRA &= ~(1<<ISC10);*/
  /*EICRA |= (1<<ISC11);*/
  
  EIMSK |= (1<<INT0);
  /*EIMSK |= (1<<INT1);*/
    
}

and its processing
ISR(INT0_vect){
  EIMSK &= ~(1<<INT0);
  //EIMSK &= ~(1<<INT1);
  
  //_delay_ms(100);
  bill_summ += 10;
  printSumm(bill_summ);

  
  //flag = 1;
  //TCNT1 = 0;
  //EIMSK |= (1<<INT1);
  EIMSK |= (1<<INT0);
}

PS - in the interrupt handling, the printSumm function is called (Output on ks0108 the sum of pulses). Even if you remove her call, and display the sum of pulses on a timer - the same glitches.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question