ADE7758 Reading IRMS register effects VRMS Value

Hello Everyone,

I am trying ADE7758 for energy metering. I have made quite a progress in my code. I could now read VRMS,IRMS and FREQ register properly. I could set VRMS , IRMS offsets for calibration and get perfect value. But i am stuck with a weird kind of problem while reading VRMS, IRMS and FREQ values together. I could get those values correctly while calculating individually but when i calculate those values together somehow my VRMS values get reduced to <2V. What i am doing is while the interrupt occurs for zero crossing, first i disable all interrupts. Then i check for which phase the interrupt has occured. Then i take a VRMS and IRMS sample and save it. Then i clear the interrupt status register(reset). Then i enable the global interrupts. I repeat this process for 20 interrupt calls and take an average value. Thats it. I am doing this but if i do this individually for VRMS and IRMS. I get the proper calibrated value. But when i join it together something goes wrong with the voltage.

I am using STM32F411.

Here is the sample code for ISR for phase A

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
	if (HAL_GPIO_ReadPin(ADE7758_INT_GPIO_Port, ADE7758_INT_Pin) == GPIO_PIN_RESET)		//Checking the interrupt pin
		__disable_irq();	//disable global interrupt				
		if (count == 0)		//if first data (ignore it)
		if (ADE7758_getInterruptStatus() & PHASE_A_STAT)		//if interrupt caused by phase A
			//get irms 
			IRMS_A_ORG = ADE7758_getIRMS(PHASE_A);		//get raw register values
			IRMS_A += IRMS_A_ORG;						
			//get vrms
			VRMS_A_ORG = ADE7758_getVRMS(PHASE_A);		//get raw register values
			Frequency_A = ADE7758_GetLineFreq(PHASE_A) * 0.0625 ;
		if (count >= 20)
			AVG_VRMS_A = VRMS_A / 20;		//take the average after 20 counts
			AVG_VRMS_A *= 0.00021275;		//for calibration
			VRMS_A = 0.0;					
			AVG_IRMS_A = IRMS_A / 20;		//take the average after 20 counts
			AVG_IRMS_A *= 0.0218160398797;	//for calibration
			IRMS_A = 0.0;
			count = 0;
		ADE7758_getResetInterruptStatus();	//Reset interrupt status register
		__enable_irq();						//enable global interrupt
	HAL_GPIO_TogglePin(GREEN_GPIO_Port, GREEN_Pin);			//toggle led