ok...tq for the explanation of the code...
basically, i want to design digital watthour meter..i have two zero crossing detector circuit which one is for voltage and another one is for current..the output from the zero crossing detector of voltage will be the input for the 8 bit binary counter. the output from the zero crossing detector of current will be the input for the latches..the zero crossing detector (voltage) means the zero crossing detector that detect the time when the voltage of the system is crossing xaxis. this detector output will clear the counter and the counter will start count again from 00000000. when the zero crossing detector (current ) has detected that the current is crossing zero, the triggering signal will latch the digital signal to the pic. 00000000 is used to represent phase shift = 0 and 11001000 represent phase shift = 360. so, basically the function of the zero crossing detector and the counter is to calculate the phase shift..