void serial_init(void)
{						//Configure UART
  T3CON = 0x83;         			//configure timer 3...ADuC848
  T3FD  = 0x12;          			//...for 9600 baud
  SCON  = 0x52;
}

void serial_read(void)
{									//Configure UART
	unsigned char c,c1,c2;		
	unsigned int i;		

//Protocol: if received "S1+cr", return MCU's status. If status is 2 then PC will ask for result
//          if received "Vn+cr" (n=1 to 9), return "n" channel ADC result

	while (RI)
	{
		c = SBUF;
		if(c==0x053 || c==0x056) //If S or V entered, store as 1st character
		{
			c1=c;
			c=0;
		}
		else
			if(c!=0x0d)   //if not the 3rd character as "cr"
				c2=c; //then  store as 2nd character

  	 	RI = 0;
		if(c1==0x053 && c2==0x031 && c==0x0d) //If received "S1+cr"
		{
			printf("%ur", MCU_Status);		
			i=0;
		}
		else
		if(c1==0x056 && c==0x0d) //If received "V(1-9)+cr"	
		{
			if(c2==0x031)                      //if received V1+cr
				printf("%ur", Head1_ADC); //send ADC result of channel 1
			else
			if(c2==0x032)
				printf("%ur", Head2_ADC);				
			else
			if(c2==0x033)
				printf("%ur", Head3_ADC);				
			else
			if(c2==0x034)
				printf("%ur", Head4_ADC);				
			else
			if(c2==0x035)
				printf("%ur", Head5_ADC);				
			else
			if(c2==0x036)
				printf("%ur", Head6_ADC);				
			else
			if(c2==0x037)
				printf("%ur", Head7_ADC);				
			else
			if(c2==0x038)
				printf("%ur", Head8_ADC);				
			else
			if(c2==0x039)
			{
				printf("%ur", Head9_ADC);	
				CONDVOL_Time_Flag=0;	//reset timer flag				
			}
		}
	}
}
