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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/27/05 13:58
Read: times


 
#93994 - LCD PROBLEM ( 4 bit )
Hi,

I've browse through other previous messages concerning LCD, read the 8052's tutorial played with it but still the LCD behaves unexpedtedly.

with my code(in C) it get configured and it remains blank, with the 8052's tutorial, its worse it doesn't even configure, I checked the pins, checked the logic, it was supposed to be working but it is not.

I searched the internet, all i got was the functions that looks like mine, but it is not working, so i don't know what is it that i am doing wrong here.

Or is there any "hidden secrets" behind "4 bit mode" cause when i enable the 8bit mode the LCD works just fine, I tried to make the delays longer to shorter. nothing changes.

I just don't know what is wrong here, I tried using another LCD just incase this was is broken, but samething happens.

Here is the connection:

LCD_D7 -> P1.7
LCD_D6 -> P1.6
LCD_D5 -> P1.5
LCD_D4 -> P1.4
LCD_RS -> P3.5
LCD_EN -> P3.4
LCD_WR -> GND

here is the code

#ifdef _8BIT
/* Writes the commands/instrunctions */
void LCD_Write_Instr (char Instr)
{
LCD_RS = 0; // Command the LCD
LCD_EN = 1; // Enable the LCD
LCD_port = Instr; // Writes the Instruction
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);
}
/* Writes an ASCII Byte on the Display */
void LCD_Write_Data (char Data)
{
LCD_RS = 1; // Select RS for Data
LCD_EN = 1; // Enable the LCD
LCD_port = Data; // Writes the Instruction
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);
}

#else
/* Writes the commands/instrunctions on 4 Bit mode */
void LCD_Write_Instr (char Instr)
{
LCD_RS = 0; // Command the LCD
LCD_EN = 1; // Enable the LCD
LCD_port = LCD_port & 0x0f; // Clear Higher Nibble
LCD_port = LCD_port | (Instr & 0xF0); // Wr Higher Nibble First
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);

LCD_RS = 0; // Selects the Register Select
LCD_EN = 1; // Enable the LCD
LCD_port = LCD_port & 0x0f; // Clear Higher Nibble
LCD_port = LCD_port | (Instr << 4); // Write Lower Nibble of Instr
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);
}

/* Writes an ASCII Byte on the Display on 4 Bit mode*/
void LCD_Write_Data (char Data)
{
LCD_RS = 1; // Data On LCD
LCD_EN = 1; // Enable the LCD
LCD_port = LCD_port & 0x0f; // Clear Higher Nibble
LCD_port = LCD_port | (Data & 0xF0); // Write Hi Nible of Data
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);

LCD_RS = 1; // Selects the Register Select
LCD_EN = 1; // Enable the LCD
LCD_port = LCD_port & 0x0f; // Clear Higher Nibble
LCD_port = LCD_port | (Data << 4); // Writes the Instruction
LCD_EN = 0; // Disables the LCD
delay_40mSec_X(1);
}
#endif

This is the initializing routine:

void LCD_init ( void )
{
delay_40mSec_X(20);
#ifdef _8BIT
LCD_Write_Instr(_8BITs); // Function Set = 0x38
LCD_Write_Instr(_8BITs); // Function set = 0x38
LCD_Write_Instr(_8BITs); // Function Set = 0x38
LCD_Write_Instr(_8BITs); // Function Set = 0x38

#else
LCD_Write_Instr(0x38); // Function Set
LCD_Write_Instr(_4BITs); // Function set = 0x28
LCD_Write_Instr(_4BITs); // Function Set = 0x28
LCD_Write_Instr(_4BITs); // Function Set = 0x28

#endif
LCD_Write_Instr(ENTRY_MODE); // Entry Mode
LCD_Write_Instr(ALL_ON);
}



List of 10 messages in thread
TopicAuthorDate
LCD PROBLEM ( 4 bit )            01/01/70 00:00      
   Try...            01/01/70 00:00      
      Tried            01/01/70 00:00      
         3 things            01/01/70 00:00      
            3 things            01/01/70 00:00      
      No hidden secrets            01/01/70 00:00      
   Re:LCD PROBLEM ( 4 bit )            01/01/70 00:00      
   write sequence not correct            01/01/70 00:00      
      Great            01/01/70 00:00      
         you are welcome            01/01/70 00:00      

Back to Subject List