Hi MARS
I can fill-in for DLath and help you further with this thread.
One correction in the formula that I would suggest is that you use LVAENERGY instead of VAENERGY. For computing the PF using energy results, use the line cycle accumulated energies for stable results.
What is the input signal applied? Over how many LINCYC do you collect energy data? Can you monitor energies and PF computed in code for various input signals applied? Try testing the code to confirm if the PF variable can indeed hold decimal point values. Also check if there is any issue with LCD segment setup (that the LCD has the capability to display decimal values).
Regards
hmani