Hi,
maybe you are running into lack of processing power.
25kHz means an interrupt repeat every 40us.
Mind the overhead needed to save and restore all variables.
hopefully means 3 clock cycles...
A display update rate of 3 times per second is enough.
Try to avoid float calculations to speed up.
Mathematically correct you should divide by 1024. This could be done by shifitng 10 bits right.. but then you loose the fractional part.
****
An alternative way is to calculate with mV (integer).
then you should perform 16 bit (ADC, left aligned) x 16 bit( 5000mV) integer multiplication.
The result should be 32bits. Use the upper 16 bits and get the result (0...5000 minus one LSB) in mV.
****
Timing:
Your interrupt runs every 40us. In main loop you wait 20 us (i see it´s marked out) ... this means you never can calculate every incoming ADC value.
I´d reduce ADC sampling rate. the wait 10ms (also marked out) seems to be your desired update rate.
So setup the ADC to perform every 10ms a new conversion (=100Hz).
In Interrupt set a flag when conversion is finished.
in main loop wait for the flag to be set (every 10 ms by interrupt) and do your calculations. Clear the flag. Every 32 calculations additinally do your display setup.
This synchronizes calculations to ADC sampling rate and saves a lot of processing power (I estimate the sayving to be about 95% or more)
Klaus