This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

display LCD not inicializate

THIS IS MY CODE

LCD2.H

--------------------------------------------------------------------------------------------

//
// MSP430 LCD Code
//
 
#include  "msp430.h"


// LCD Port assignement
#define LCD_DIR P1DIR
#define LCD_OUT P1OUT


// Lcd Pin assignement
#define LCD_PIN_RS BIT0
//#define LCD_PIN_RW BIT7
#define LCD_PIN_EN BIT1
#define LCD_PIN_D4 BIT2
#define LCD_PIN_D5 BIT3
#define LCD_PIN_D6 BIT4
#define LCD_PIN_D7 BIT5


void LCDPulseEN(void);
void LCDSetPosition(char Row, char Col);

// Procedure to strobe data to LCD register
void LCDPulseEN(void)
{ // Set Enable active
  __delay_cycles(20);
  LCD_OUT |= LCD_PIN_EN;
  __delay_cycles(20);
  // Release Strobe
  LCD_OUT &= (~LCD_PIN_EN);
}

// this send 4 bit of data
void SendNibble(char data)
{
  // Clear all data bit
  LCD_OUT &= ~(LCD_PIN_D4|LCD_PIN_D5|LCD_PIN_D6|LCD_PIN_D7);
  // Set data bit on port bit
  if(data & 0x01)
    LCD_OUT |= LCD_PIN_D4;
  if(data & 0x02)
    LCD_OUT |= LCD_PIN_D5;
  if(data & 0x04)
    LCD_OUT |= LCD_PIN_D6;
  if(data & 0x08)
    LCD_OUT |= LCD_PIN_D7;
  // Nibble set complete, send to LCD
  LCDPulseEN();
  __delay_cycles(500);
}

// Send a byte of data to LCD register
void SendByte(unsigned char data)
{
  SendNibble((data>>4) & 0x0F);
  SendNibble((data) & 0x0F);
  __delay_cycles(500);
}

// send a byte to command register
void SendInstruction(unsigned char data)
{
  // Set Register to command
  LCD_OUT &= ~LCD_PIN_RS;
  SendByte(data);
  __delay_cycles(80000);
}

// Send a byte of data to LCD register
void LCDputch(unsigned char data)
{
  // Set Register to data
  LCD_OUT |= LCD_PIN_RS;
  SendByte(data);
  __delay_cycles(500);
}



void InitLCD(void)
{
  // clear all bit of LCD control & data Lines
  LCD_OUT &= ~(LCD_PIN_EN|LCD_PIN_RS); //|LCD_PIN_RW);
  // Set LCD pins to output
  LCD_DIR |=(LCD_PIN_EN|LCD_PIN_RS|LCD_PIN_D4|LCD_PIN_D5|LCD_PIN_D6|LCD_PIN_D7); // |LCD_PIN_RW
  // wait Powerup
  __delay_cycles(100000);
  // LCD can be in an unknown state so set to a known state sending 3 times LCD set to 8 bit mode
  SendNibble(3);
  __delay_cycles(16000);  // Wait for init
  SendNibble(3);
  __delay_cycles(400);
  SendNibble(3);
  __delay_cycles(400);
  // now is 8 bit, sending 2 set mode to 4 bit (0x2n)
  SendNibble(2);
  __delay_cycles(800);
  // Now set to mode 4 bit 2 line 5x7 char
  SendInstruction(0x28);
  __delay_cycles(8000);
  // Make cursor visible one line set to 0x0c to invisible cursor
  SendInstruction(0x0C);//c
  __delay_cycles(800);
  // Clear screen
  SendInstruction(0x01);
  __delay_cycles(8000);
  // Increment address mode
  SendInstruction(0x06);
  __delay_cycles(8000);
  // Set write data address to 0
  SendInstruction(0x80);
}

// Set write cursor to Row and Col
void LCDSetPosition(char Row, char Col)
{
  // if row is not 0 add 0x40 (4 line models require adding 0 20 60 40)
  if(Row)
    Col+=0x40;
  SendInstruction(0x80 | Col);
  __delay_cycles(800);
}

// Clear LCD
void LCDClear(void)
{
SendInstruction(0x01);
  __delay_cycles(100000);
}

// Lcd cursor to first row first column
void LCDGoToHome(void)
{
SendInstruction(0x02);
  __delay_cycles(100000);
}

// Shift left mode
void LCDShiftLeft(void)
{
SendInstruction(0x18);
}

// Shift right mode
void LCDShiftRight(void)
{
SendInstruction(0x1C);
}

// Cursor blinking mode
void LCDBlinkCursor(void)
{
SendInstruction(0x0F);
}

// Print a text line to LCD screen
void LCDPrintString(const char * Text)
{
  while (*Text)
    LCDputch(*Text++);
}

-------------------------------------------------------------------------

MAIN

-___________________________________________________________-

#include "lcd2.h"
#include "msp430.h"

void main (void)
{

  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;

  InitLCD();
  LCDPrintString("Hello world");
 
 
}

____________________________________________________________---

MY DISPLAY LCD S JHD 162A

THIS IS MY  CONNECTION

http://imageshack.us/photo/my-images/836/imagemdem.jpg/

my inicialization, or write anything in displya don´t work.....

______________________________________________________________

what the happen? the lcd is new....

my lcd not inicializate or write :(

**Attention** This is a public forum