Is curve fitting to a sinusoidal function with Microcontroller possible?
I have no clue why you want this stuff. And Tony is asking and you aren't answering. So I'm just going to take you literally and answer that.

A general method to find the phase difference between two identical signals is to use a correlator. This works even for speech and music. In the digital domain, just cross-correlate them. The local maximum in the correlation function will be at the time delay \$\delta\$. If you have a reference signal, you can just correlate against that one, too. Correlation is dead easy, too. You can find a very simple routine for it just about anywhere you look. Just a few lines of code, really.

There's an old paper from 1963 called "The Quefrency Analysis of Time Series for Echoes: Cepstrum, Pseudo-autovariance, Cross-Cepstrum, and Saphe Cracking" by Bogert et al. You might find it worth reading, as well.