Determining 1st and 2nd harmonic sounds feasible even with a slow (1 MIPS) standard 8051, e.g. using Goertzel algorithm. It depends however on the sampling frequency and bit resolution, which hasn't been told at all. You would want a low sampling rate not much above the minimal (Nyquist) rate. A good analog filter would be required to avoid aliasing of higher order harmonics.
The sampling frequency is 12 khz... it follows the Nyquist theorum...N=250, required frequencies are 50 Hz(fundamental) and its second harmonic.......this gives k=1.04(k=N*Fs/Fk)
This is the Goertzel code being used(not running)
static int N=0;
static int goertzel value=0;
int I,prod1,prod2,prod3,sum,R_in,output;
short input;
short coef_1=0x7ff5;
R_in=mcbsp0_read();
input=(short)R_in;
input=input>>4;
prod1=(delay_1*coef_1)>>14;
delay=input+(short)prod1 - delay_2;
delay_2=delay_1;
delay_1=delay;
N++;
if (N== )
{
prod1=(delay_1 * delay_1);
prod2=(delay_2 * delay_2);
prod3=(delay_1 * coef_1)>>14;
prod3=prod3*delay_2;
Goertzel_value=(prod1 + prod2 - prod3)>>15;
Goertzel_value <<=4;
N=0;
}
output=(((short)R_in)*((short)Goertzel_value))>>15;
mcbsp_write(output& 0xfffffffe);
return;
}