Jump to content
43oh

Launchpad & LCD character display


Recommended Posts

I am trying to use my launchpad with a g2152 to write to an LCD. I have a 3.3volt LCD from New Haven Display (http://www.newhavendisplay.com/specs/NHD-0216HZ-FSW-FBW-3V3C.pdf). I am pretty sure I have it wired up correctly, I have torn it all down and reconnected everything just in case. This thing is driving me up the wall. The code is pretty much ripped straight from NewHaven's forums and double checked with the datasheet. I don't know where I could have gone wrong. Any hints?

 

//---------------------------------------------------------
/*
8_bit_character.c
Program for writing to character LCD
*/
//---------------------------------------------------------


#include "msp430x22x4.h"
//---------------------------------------------------------
//
//#define E	 	 P2_2;
//#define D_I	 P2_0; register select
//#define R_W	 P2_1;
//******************************************************************************



char const text1[] = {"Test Program    "};
char const text2[] = {"Character LCD   "};



void Delayms(int n){
do __delay_cycles(10000); while(--n);
}

void command(char i){
P1OUT = i;
P2OUT &= ~0x01;		//DI P2_0 =0;
P2OUT &= ~0x02;		//R_W P2_1 =0;
P2OUT |= 0x04;		//e P2_2  = 1;
Delayms(1);
   P2OUT &= ~0x40;		//e P2_2  = 0; falling edge
}
void write(char i){
P1OUT = i;
P2OUT |= 0x01;		//DI P2_0 =1;
P2OUT &= ~0x02;		//R_W P2_1 =0;
P2OUT |= 0x04;		//e P2_2  = 1;
Delayms(1);
   P2OUT &= ~0x40;		//e P2_2  = 0; falling edge
}
void init(){
P2OUT &= ~0x40;		//e P2_2  = 0;
Delayms(100);
command(0x30);
Delayms(30);
command(0x30);
Delayms(10);
command(0x30);
Delayms(10);
command(0x38);
command(0x10);
command(0x0c);
command(0x06);
}
void home(){
command(0x01);
Delayms(5);
}
void nextline(){
command(0xc0);
}
void disp_pic(){
int i;
home();
for (i=0;i<16;i++){
	write(text1[i]);
}
 nextline();
 for (i=0;i<16;i++){
	write(text2[i]);
}
}


void main(void) {
WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
P1DIR = 0xFF;		 //set p1 as output
P2DIR = 0xFF; 		 //set p2
P1OUT = 0x00;
P2OUT = 0x00;
while(1){
	init();
	disp_pic();
	Delayms(1000);
}
}


Link to post
Share on other sites

IT WORKED! I am so stoked. Sorry that I have to bother everyone with my stupid errors. I feel dumb.

So I think this version, the 3v version, of the LCD is supposed to have the contrast internally set. But the screen is really dark and you can hardly see the text? Any ideas on how to fix that? Should I just start messing with pin 3, which is supposedly a no-connect?

 

edit* I disconnected the Vss pin on the screen and now my contrast is awesome. However, I am baffled how this screen works without having the ground pin connected to anything? And why would that screw up my contrast?

Link to post
Share on other sites

where is your lcd V0 / pin 3 goes? a typical setup is to have it (pin3) get a voltage split from a 10k trim pot (across pin 1 and 2), this will allow you to control the contrast by turning the pot.

 

alternatively if u are in love and crazy about controlling lcds, u can do a pwm out to pin 3 and control the contrast via firmware.

Link to post
Share on other sites
Yeah, this LCD however has pin three listed on the datasheet as a n/c. Just because it is a 3.3v LCD instead of 5v.

 

i see, well, u may still experiment as a lot of lcd modules have both 3.3v and 5v versions share the same pcb.

 

i am not qualify to explain why your lcd still works w/o pin 2 connected. but my experience is that the gnd is still there via other io pins. ex. like u are still providing gnd via the read / write select pin. that pin may have a pull down resistor connecting to pin 2. this may also explain V0 bias voltage is different and impacts contrast.

 

but u should not rely on such setup as a solution.

Link to post
Share on other sites

Yeah, after coming back a day later to play with this further the contrast is still super dark and when I disconnect the ground pin the contrast then goes way too light. I am thinking that if the contrast is supposed to be internally set then there isn't an easy way to mess with the contrast and I probably just got a bad screen.?

Link to post
Share on other sites

I read somewhere (on a Newhaven forum I think) that these displays use the supply voltage to set contrast. I had one powered by a Launchpad and it had poor contrast.

 

It's wired in to a project powered at 3.6V. The contrast was still poor so I added a 39 ohm resister in series with the supply voltage and that fixed the contrast problem.

 

I also added a 39 ohm resistor between the 3.6V and the LED supply and the measured current was what was specified in the data sheet.

Link to post
Share on other sites
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...