Paul, if you take out your spin loop in the ISR you'll have a lot more time for everything else. You should have your ISR that triggers in the middle of the pwm (TIMER1_OVF_vect) start the ADC, then have the ADC trigger an ISR on completion (Bit 4 – ADIF: ADC Interrupt Flag). The ADIF then makes the current available to the main loop.
|