=Result * 2430 / 4095;  //Result is coming from ADC_Procedure

	EA = 1;                          // Re-enable interrupts
	Time0 = ~Time0;					// generate clk at output for frequency check
	counter2++;						// counts # of samples


	Delay_ms(100);
	x1= measurement[buf];				//low value 8bit
	x2= measurement[buf] >> 8 ;			//high value 8bit (recalculated with *256)
	SFRPAGE   = UART1_PAGE;
	//printf("n x1:%d x2:%d",x1,x2);
	printf("n meas_value:%ld x1:%d x2:%d counter:%ld",measurement[buf],x1,x2,counter);
	SFRPAGE   = SPI0_PAGE;
   SPIF     = 0;
   NSSMD0   = 0;
		
   SPI0DAT  = 166;				//perform test (with constant value)
   while (!SPIF);

   SPIF     = 0;
   NSSMD0   = 1;
   //Delay_us (1);
   

   }	 //for end

   // Step5: Poll on the Write In Progress (WIP) bit in Read Status Register
   do
   {
      NSSMD0   = 0;                    // Activate Slave Select
      SPI0DAT  = EEPROM_CMD_RDSR;      // Send the Read Status Register command
     while (!SPIF);                   // Wait for the command to be sent out
      SPIF     = 0;
      SPI0DAT  = 0;                    // Dummy write to output serial clock
     while (!SPIF);                   // Wait for the register to be read
      SPIF     = 0;
      NSSMD0   = 1;                    // Deactivate Slave Select after read
    //  Delay_us (1);
   } while( (SPI0DAT & 0x01) == 0x01 );

   SFRPAGE  = save_sfrpage;
	counter=counter+64;				//go to next page

	}	//while end	 	
