crobertsbmw 0 Posted December 16, 2011 Share Posted December 16, 2011 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); } } Quote Link to post Share on other sites
crobertsbmw 0 Posted December 16, 2011 Author Share Posted December 16, 2011 Quote Link to post Share on other sites
ike 53 Posted December 16, 2011 Share Posted December 16, 2011 Can you tell me what this line do? P2OUT &= ~0x40; //e P2_2 = 0; falling edge Quote Link to post Share on other sites
crobertsbmw 0 Posted December 16, 2011 Author Share Posted December 16, 2011 It's the operational enable signal. Which is falling edge triggered. So you take it high, turn on whichever signals and then drop it low. Quote Link to post Share on other sites
ike 53 Posted December 16, 2011 Share Posted December 16, 2011 Well, what are you waiting for? Drop it low. Quote Link to post Share on other sites
simpleavr 399 Posted December 16, 2011 Share Posted December 16, 2011 P2OUT |= 0x04; //e P2_2 = 1; Delayms(1); P2OUT &= ~0x40; //e P2_2 = 0; falling edge } your 'e' line looks like was intended to be p2.2, which translates to 0x04. but when u set it low, u are actually setting p2.6 low. looks like u can try and replace all 0x40 w/ 0x04, or better yet BIT2. crobertsbmw 1 Quote Link to post Share on other sites
crobertsbmw 0 Posted December 17, 2011 Author Share Posted December 17, 2011 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? Quote Link to post Share on other sites
simpleavr 399 Posted December 18, 2011 Share Posted December 18, 2011 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. Quote Link to post Share on other sites
crobertsbmw 0 Posted December 18, 2011 Author Share Posted December 18, 2011 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. Quote Link to post Share on other sites
simpleavr 399 Posted December 19, 2011 Share Posted December 19, 2011 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. Quote Link to post Share on other sites
crobertsbmw 0 Posted December 19, 2011 Author Share Posted December 19, 2011 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.? Quote Link to post Share on other sites
websterling 12 Posted December 19, 2011 Share Posted December 19, 2011 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. Quote Link to post Share on other sites
Manjit 0 Posted February 24, 2012 Share Posted February 24, 2012 can u post the pin layout pls? im alsov have trubble connecting my launchpad to my lcd :S Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.