I need to calculate frequency in centy Hz (eg. 0.01 Hz precision) from a variable period.
I'm measuring line frequency from timer counter since last zero cross.
Target is Atmega328.
Currently i do the calculation like this: HZ=K/p;
//cHz range 4444-6666 (44.44-66.66Hz);
//PERIOD range 360000-240000 (320000 is the most occurence expected on 50hz line)
#define F_CPU 16000000
unsigned long cHZ,PERIOD ;
cHZ = (unsigned long)(F_CPU*100) / PERIOD ;
How to improve speed on this specific division?
F_CPU is constant and should not change. Code portability is not an issue.