I have a TI MSP430x2274 that I am trying to interface with an LCD (http://shop.moderndevice.com/products/3-3v-16-x-2-blue-lcd-character-display). I have it all wired up, but I can't get anything to show up. I wonder just a little bit if they sent me a 5volt version and not the 3.3 volt version and I don't have high enough voltage for the contrast or something. Or maybe something is wrong with my code. The code is an adaptation of the sample code from newHaven Display. I compared the two data sheets and they seem to be exactly the same. Any other ideas why I might not be able to get anything written to this LCD?
Here is my code:
Here is my code:
Rich (BB code):
//---------------------------------------------------------
/*
8_bit_character.c
Program for writing to character LCD
*/
//---------------------------------------------------------
//#include <lcdTest.h>
#include "msp430x22x4.h"
#include "eZ430X.h"
//---------------------------------------------------------
//
//#define E P3_4;
//#define D_I P3_0;
//#define R_W P3_7;
//******************************************************************************
char const text1[] = {"Test Program "};
char const text2[] = {"Character LCD "};
void Delayms(int n){
int i;
int j;
for (i=0;i<n;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);
}
nextline();
for (i=0;i<16;i++){
write(text2);
}
}
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR = 0xFF; //set p1.0-p1.7 as output
P3DIR |= 0xC1; //set p1.0 p1.6 and p1.7 as output
P1OUT = 0x00;
P3OUT = 0x00;
while(1){
init();
disp_pic();
Delayms(1000);
}
}
Last edited by a moderator: