Hello!
I am having some troubles with reading a 500,000Hz signal (a complete cycle is 2us) in the atmega328 (same with the atmega168). I am having a variable increment by one every time there is a change in the pin, but the timing is not precise... Well, here is the code:
volatile int32_t timer; void setup() { EICRA |= (1<<ISC10); EIMSK |= (1<<INT1); EIFR |= (1<<INTF1); sei(); } ISR(INT1_vect) { timer++; }
When the variable timer reaches a number higher than 100,000 I have a LED that should be turned on.. It should take 1 second, but it is taking forever to turn on the LED (more than 1 min).
Is the signal too fast for the MCU?
Thanks in advance