Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help For PIC to LCD display

Status
Not open for further replies.

toussaint

Newbie level 1
Joined
Sep 6, 2008
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
pic latd

Hello guys...
I am working on my project using a Pic 16F887. I am doing ADC on an input signal at 50 HZ . I need to display the result on LCD (LM162ABC-1 ) but I can't.
my problems are as follow:
- After connecting the LCD what message are we suppose to see on screen?
- can somebody help me with the drivers for that LCD?

I am programming in assembler.
I will appreciate any form of help. [/i][/b]
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,863
16f887 lcd

Here is the code I use for a 2 line 20 char lcd display using the Pic 16-bit micros.
This uses an 8-bit interface. Attached is a pdf with the lcd commands.
Should be possible to convert it to assembler.

Code:
/*--- Macros ---*/

#define RS      LATDbits.LATD8
#define RS_TRIS TRISDbits.TRISD8

#define RW      LATDbits.LATD9
#define RW_TRIS TRISDbits.TRISD9
 
#define E       LATDbits.LATD10
#define E_TRIS  TRISDbits.TRISD10 

/*--- Display commands ---*/

#define CLEAR     0x01U
#define LINE2     0xc0U
#define C_RIGHT   0x14U
#define SHIFT     0x1CU
#define HOME      0x02U 

/*--- Local function prototypes ---*/
    
static void write_command(char cmd);          
static void write_data(char data);        
static void puts_lcd(char *data);
static void Strobe_E(void);
static Bool BusyFlag(void);


/*--- Initialise lcd display ---*/

void init_lcd(void)
  {
  delay_mS(15);    /* Reset delay */
  LATD = 0;       
  TRISD = 0;
                     
  LATD |= 0x0038; /* 1st LCD initialization sequence */
  Strobe_E();
  delay_mS(5);

  Strobe_E();     /* 2nd LCD initialization sequence */
  delay_mS(1);

  Strobe_E();     /* 3rd LCD initialization sequence */
  delay_mS(1);

  write_command(0x38);
  write_command(0x0c);
  write_command(0x06);  
  }

/*--- Write command to display ---*/

static void write_command(char cmd) 
  {
  LATD &= 0xff00;   
  LATD |= cmd;
  RW = 0;                       
  RS = 0;
  Strobe_E();

  while(BusyFlag()){
    ;
    } 
  }

/*--- Write data to display ---*/

static void write_data(char data )        
  {
  RW = 0;                
  RS = 1; 
  LATD &= 0xff00;   
  LATD |= data;
  Strobe_E();
  RS = 0;

  while(BusyFlag()){
    ;
    }
  } 

/*--- Write string to display ---*/

static void puts_lcd(char *data) 
  {
  while(*data){
    write_data(*data++);
    } 
  }

/*--- Read busy flag ---*/

static Bool BusyFlag(void)
  {
  uint8_t result;

  TRISD |= 0x00ff; 
  RW = 1;                
  RS = 0;
  Strobe_E();
  result = PORTD & 0x00ff;
  TRISD = 0;
  return result & 0x80;
  }

/*--- Strobe E ---*/

static void Strobe_E(void)
  {
  E = 1;  
  Nop();
  Nop();
  Nop();
  E = 0;       
  }

/*--- End of File ---*/

Hope this helps.
 

TekUT

Full Member level 6
Joined
Jun 17, 2008
Messages
323
Helped
39
Reputation
78
Reaction score
15
Trophy points
1,298
Location
Italy
Activity points
3,557
16f887 adc lcd

I've written a complete tutorial on the subject for 4-bit interface, look at this thread:



Hope it can help a bit.

Bye
Pow
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top