| ??? 02/11/03 10:51 Read: times |
#38766 - RE: interfacing lcd in c (4bit) init Responding to: ???'s previous message |
When plugging the LCD, often, as it is not initialized, one of the lines (for a 2x16) is filled in black. After your init sequence, this should erase all the LCD.
You should change your lcdwrite function to take care of the upper & lower nible of your instruction or data to LCD. It will help you. Are the instructions data correctly set on the port ? In your code, I don't see any modification of the RS pin allowing to change between instructions and datas to the LCD This should be included for example in you lcdwrite function. Without this, you won't be able to display anything. I'havent checked the two last 0x08 sequence you sends. In my code, you can see 0x0c instead, and so on .... Check that it's not your problem. Your remaining code sounds good for me. I've added some comments in my code below. It may help you
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 */
}
}
|
| Topic | Author | Date |
| interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
RE: interfacing lcd in asm (4bit) | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 | |
| RE: interfacing lcd in c (4bit) init | 01/01/70 00:00 |



