
void HLCD_LcdInit(void)
{
	Pause ();
	
	PIA_ORA=0x38; // E=1, RS=0, RW=0
        Pause ();
        PIA_ORA=0x30; // E=0, RS=0, RW=0
        Pause ();
       
        PIA_ORA=0x38; // E=1, RS=0, RW=0
        Pause ();
        PIA_ORA=0x30; // E=0, RS=0, RW=0
        Pause ();
      
        PIA_ORA=0x38; // E=1, RS=0, RW=0
        Pause ();
        PIA_ORA=0x30; // E=0, RS=0, RW=0
        Pause ();
      
        PIA_ORA=0x28; // E=1, RS=0, RW=0
        Pause ();
        PIA_ORA=0x20; // E=0, RS=0, RW=0
        Pause ();
        
        
        LcdWrite(2,"x28"); /* Function set : 4 bits interface, no shift */
        LcdWrite(2,"x0C"); /* Display control : display on, cursor off, blink off */
        LcdWrite(2,"x06"); /* Entry mode set : increment mode, no display shift */
        LcdWrite(2,"x02"); /* return home */
        LcdWrite(2,"x01"); /* clear display */
                
	Pause ();                
}


/*-------------------------------------------------------------------
Send datas or instructions to the LCD display
	LcdWrite(U8 func,U8 *txt)
		u8Function = 1 : *txt contains datas
		u8Function = 2 : *txt contains instructions 
--------------------------------------------------------------------*/
void LcdWrite(U8 u8Function,U8 *au8String)
{	
	U8 u8InstData,u8Upper,u8Lower;
	
	/* datas */
	if (u8Function == 1) 
		{
		u8InstData = 0 | RS & ~RW;
		}
		
	/* instructions */	
	if (u8Function == 2) 			
		{
		u8InstData = 0 & ~RS & ~RW;
      		}
		
	/* Send the chain to the LCD display */		
	while (*au8String !=0)
		{
			u8Upper = *au8String & 0xF0 | u8InstData; /* RS=1 */
			u8Lower = (*au8String << 4) & 0xF0 | u8InstData; /* RS=1 */
			
			PIA_ORA = u8Upper | E; 
  			Pause ();
  			PIA_ORA = u8Upper & E;
  			Pause ();
  			PIA_ORA = u8Lower | E;
  			Pause ();
  			PIA_ORA = u8Lower & E;
  			Pause ();
  		
  			au8String++; /* next character */
		}
}
