1
\$\begingroup\$

I have successfully wired everything together and the LCD powers up fine. Its a 16x2 display. The one problem i see is that when the LCD gets power, one of the rows is visibly darker than the other one. Someone told me that i needed to initialize the LCD screen first in order for me to use it.

I have the datasheet available. In it it even tells me which hex codes i need to send to clear the display/turn on the cursor etc...

Screencap of the datasheet

I feel dumb for asking because i feel like i should already know this but eactly how do i send these hex codes from the microcontroller? And where are they supposed to go? The datasheet assumes I should already know this. Heres an example of what i did to try and send these codes:

P1OUT = 0x38;
__delay_cycles(10000);
P1OUT = 0x38;
__delay_cycles(10000);
P1OUT = 0x38;
__delay_cycles(10000);
P1OUT = 0x38;
__delay_cycles(10000);
P1OUT = 0x06;
__delay_cycles(10000);
P1OUT = 0x0E;
__delay_cycles(10000);
P1OUT = 0x01;
__delay_cycles(10000);
P1OUT = 0x80;
__delay_cycles(10000);

I dont think I Am i doing this right. Nothing on the screen changes.

*Added Timing Diagrams enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Are you running the uC and the LCD on 5V? \$\endgroup\$ May 25, 2015 at 19:03
  • \$\begingroup\$ the MSP430 runs on 3.5V and im using a pin on the uC that gives me 5v for the lcd. like i said everything powers up fine. but i dont know how initialize it. \$\endgroup\$ May 25, 2015 at 19:11

2 Answers 2

1
\$\begingroup\$

You can't just ignore the RS, RW & E lines.
RS & RW must be driven correctly - for sending commands to the LCD, both must be low as the datasheet indicates.
E must be toggled from low to high and back to low again for each and every initialisation command byte.
Depending on the clock speed of your micro, you may need to add some delays into the E toggling sequence to make sure that your bytes are being correctly latched into the LCD. The LCD datasheet tells you what its timing requirements are (Enable Cycle Time, etc) but only you know how fast your micro is running.
I'm assuming you have already wired the data lines between your micro and the LCD sensibly ...

\$\endgroup\$
4
  • \$\begingroup\$ yea. im not ignoring them. honestly i havent even seet RS and R/W low like i should have. its a 16 mhz cpu. im pretty sure i have the delays down. I just want to know when it comes time to actually send a hex code to the lcd what statement would i use to send it? if its something as simple as saying P1OUT = <some hex #>; or if its being sent by something like send_command(); \$\endgroup\$ May 26, 2015 at 14:55
  • \$\begingroup\$ While P1OUT = <some hex #> tells your micro to put <some hex #> out on P1, it doesn't tell the LCD to read it. That's what toggling the E pin high/low does. So it might be a good ides for you to write a send_command() which does the full 'P1OUT = <some hex #>; toggle E high; toggle E low;' sequence with appropriate delays. \$\endgroup\$
    – brhans
    May 26, 2015 at 15:37
  • \$\begingroup\$ And remember you're going to have to do something similar when you get around to sending text to the LCD too, except in that case RS must be high instead of low. \$\endgroup\$
    – brhans
    May 26, 2015 at 15:38
  • \$\begingroup\$ Thank you that answers my question perfectly. Ill keep working on this. \$\endgroup\$ May 26, 2015 at 18:12
1
\$\begingroup\$

As given in the datasheet, the delays are not identical. The first few delays must be longer since you need to allow for the LCD controller to fully initialize before sending it further commands.

Also, you need to strobe the E input each time, as shown in the timing diagrams.

\$\endgroup\$
9
  • \$\begingroup\$ what does strobe mean? The datasheet briefly at the beginning mentions to "enable strobe (E)" but no other occurrence of it anywhere. how do i do this? \$\endgroup\$ May 25, 2015 at 19:16
  • \$\begingroup\$ Do you have the timing diagrams in front of you? \$\endgroup\$ May 25, 2015 at 19:28
  • \$\begingroup\$ I do. I just edited the main post and added a screencap of the diagrams. I dont know how to go about reading these. \$\endgroup\$ May 25, 2015 at 19:33
  • \$\begingroup\$ They show the change of the interface pins over time. One of them is the E line. The safe way to use this line is to set everything (RS, RW and data) up, short wait (start with 1ms), then make E high, short wait, make E low, long wait (start with 20ms). PS how are you handling RS and RW? \$\endgroup\$ May 25, 2015 at 19:57
  • \$\begingroup\$ I guess im not handling them at all yet. It says for initialization that R/W and RS should be 0 but i havent done that yet. Wouldn't setting P1OUT to 0 set all the pins (including the R/W and RS pins) to 0? \$\endgroup\$ May 25, 2015 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.