[email protected] said:
> I'm a little concerned about the speed at which the pulses need to be
> counted. The 32kHz pulses come in every ~30.5 microseconds, and handling an
> interrupt on an ATmega328 running at 16MHz takes about 5.125 microseconds[1]
Huh?
Instruction cycle time is 62.5nS for almost all instructions at that clock.
That’s a pretty long ISR by my standards.
1: Reserve a couple of registers for handling data inside ISRs, avoiding push
and pop.
2: Reserve a register for holding SREG during the ISR.
ISR: in STEMP,SREG
At this point you can fearlessly trash SREG and ITEMP and ITEMP2
Do Stuff using ITEMP and ITEMP2.
Do as little as practical in the ISR, letting the non-isr code do the
heavy lifting.
Out SREG,STEMP
RETI
Optionally, set a register (I usually call it "ZERO") to 0x00 to speed up 16
bit operations.
Keep data you need FAST in registers in the low page, rather than in RAM.
_______________________________________________
time-nuts mailing list -- [email protected]
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.