Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/20/02 17:11
Read: times


 
#29448 - RE: 4 bit LCD initialisation / Peter
Hi Phee
Sorry I don't know assembly for the 8052, I programmed my LCD in 4 bit mode using hi-tech C compiler for PIC. Here is my quick first version of my initialization routine that worked, compare it to yours
/******************************************************************************
* Name:    LCDD_Initilise
******************************************************************************/
void LCDD_Initialise()
{
    RS = 0;	        // write control bytes(RS -> PORTB bit3)
    DelayMs(15);	// power on delay
    PORTB = 0x30;	// attention!
    ECLOCK();
    DelayMs(5);
    ECLOCK();
    DelayUs(100);
    ECLOCK();
    DelayMs(5);
    PORTB = 0x20;	// set 4 bit mode
    ECLOCK();
    DelayUs(40);
    LCDD_WriteCommand(0x28);	// 4 bit mode, 1/16 duty, 5x8 font
    LCDD_WriteCommand(0x08);	// display off
    LCDD_WriteCommand(0x0F);	// display on, blink curson on
    LCDD_WriteCommand(0x06);	// entry mode
    DelayMs(5);
    LCDD_WriteCommand(DispCLR);
    LCDD_WriteCommand(RetHome);
}
/******************************************************************************
* Name:    LCDD_WriteCommand
******************************************************************************/
void LCDD_WriteCommand(byte nibbles)
{
    byte hiNibble = nibbles;
    DelayMs(1);
    hiNibble = hiNibble & 0x0f0;
    PORTB = hiNibble;
    ECLOCK();
    DelayMs(1);
    hiNibble = (nibbles << 4);	// get lower nibble and shift it hi
    PORTB = hiNibble;		// output lower 4 bits
    ECLOCK();
    DelayMs(1);
}
/******************************************************************************
* Name:    ECLOCK
******************************************************************************/
void ECLOCK()
{
    DelayUs(1);			// tas delay 
    E = HI;			// for write cycle only
    DelayUs(2);
    E = LOW;
    DelayUs(1);
}   


List of 17 messages in thread
TopicAuthorDate
4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
   RE: 4 bit LCD initialisation / Peter            01/01/70 00:00      
RE: 4 bit LCD initialisation            01/01/70 00:00      
RE: 4 bit LCD initialisation : My C code            01/01/70 00:00      

Back to Subject List