Jump to content
43oh

Character Display


Recommended Posts

I have a character display that I am trying to write to. I even got a 3.3v one because I thought it would be easier than trying to deal with one that needs 5.0volts. I set up a test blinky program on my msp430x2274 so I know I am getting my code onto the microcontroller but then when I try to run my program for the LCD, I get no response from the LCD. I have looked over my code and feel like it is pretty sound. It's mostly a rip off from some newhaven display sample code, but I did have to change it a little bit for it to work for me. This is the LCD I am using http://cdn.shopify.com/s/files/1/0038/9 ... 1260727644. I was going to use a newHaven display but the one I ordered has pins that are like 1mm apart and I cant find a header that small nor can I solder wires onto something that small, so I am using this Longtech one. Can you spot anything goofy with my code?

 

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

#include "msp430x22x4.h"
#include "eZ430X.h"
//---------------------------------------------------------
//
//#define E	 P3_4;
//#define D_I	 P3_0;
//#define R_W	 P3_7;
//******************************************************************************
//	LED's
#define LED_GREEN_ON		P1OUT |= 0x02; // set
#define LED_GREEN_OFF		P1OUT &= ~0x02; // clear
#define LED_GREEN_TOGGLE	P1OUT ^= 0x02; // toggle

//******************************************************************************
// DISABLE THE WATCHDOG!!!


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

void Delayms(int n){
int i;
int j;
for (i=0;i		for (j=0;j<1500;j++)
	{;}
}

void command(char i){
P1OUT = i;
P3OUT &= ~0x01;		//P3_0 =0;
P3OUT &= ~0x80;		//P3_7 =0;
P3OUT |= 0x40;		//e P3_6  = 1;
Delayms(1);
   P3OUT &= ~0x40;		//P3_6  = 0;
}
void write(char i){
P1OUT = i;
P3OUT |= 0x01;		//P3_0 =1;
P3OUT &= ~0x80;		//P3_7 =0;
P3OUT |= 0x40;		//P3_6  = 1;
Delayms(1);
   P3OUT &= ~0x40;		//P3_6  = 0;
}
void init(){
  // P3OUT &= ~0x10;		//E = P3_4  = 0;
   P3OUT &= ~0x40;     //E = P3.6 = 0;
Delayms(5);
command(0x30);
Delayms(100);
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 = 1;
P3DIR = 1;
P1OUT = 0x00;
P3OUT = 0x00;
while(1){
	init();
	disp_pic();
	Delayms(1000);
}
}


Link to post
Share on other sites

The first problem I see is this:

 

 P1DIR = 1;
P3DIR = 1;

You are using all ports on P1 as outputs, so you should have 0xFF instead of 1

On P3, you are using 0, 6, and 7 as outputs, so it should be BIT0 + BIT6 + BIT7

 P1DIR = 0xFF;
P3DIR = BIT0 + BIT6 + BIT7;

Also, remove all unrelated code, like LED_GREEN and other defines, it just adds confusion

Link to post
Share on other sites

Thanks Rob.

It always seems obvious when someone else points it out to you. In addition to that error, the datasheet is for this LCD is wrong. It has Vdd and Vss flipped. Or maybe I have it flipped, but I thought traditionally Vdd was supposed to be your supply voltage while Vss was your ground. I now at least can get the LCD to put off light. I am now having trouble with getting the debugger to work, and I am going to talk to one of my professors tomorrow and see if he can help me troubleshoot the thing.

Thanks again Rob.

-Chase

Link to post
Share on other sites

So, I thought that maybe I was just getting the contrast off on this thing. It's supposedly a 3.3v model so I hooked up an external power supply to Vo and raised the voltage to 4.2, 4.5, 4.8, 5.0 Still nothing. Am I supposed to see black bars or anything? The back-light is on but that's about all I can get. Any ideas would be so awesome.

Link to post
Share on other sites

Disconnect your LCD from any control/data lines. Turn on your power supply. you should see black bars. Adjust your contrast by adjusting the resistance on the contrast control line till it is halfway in between dark and invisible. This will at least guarantee that your characters will be seen.

Link to post
Share on other sites
  • 1 month later...

Allright I tried throwing a pot on there and I couldn't get any gray squares to show up. This LCD from NewHaven,

 

http://www.mouser.com/ProductDetail/New ... 2s1Q%3d%3d

 

just has the contrast pin as a no connect. Could it be that the contrast for this other LCD is the same deal and that it is internally set? I am baffled as to why I cannot get this thing to work..

Link to post
Share on other sites

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...