Continue to Site

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.

2x16 lcd display using pic16f877

Status
Not open for further replies.

madusanka

Newbie level 5
Joined
Jul 25, 2010
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
srilanka
Activity points
1,366
hello , im new to LCD module,i wrote a C code using mikroC help files,its working PROTEUS but when i make that one it didnt work,, can somebody give me hex code for check the 2x16 LCD display and connections.
Anybody...?:roll:
 

/*
* Project name:
Lcd_Test (Demonstration of the LCD library routines)
* Copyright:
(c) Mikroelektronika, 2008.
* Revision History:
20080930:
- initial release;
* Description:
This code demonstrates how to use LCD 4-bit library. LCD is first
initialized, then some text is written, then the text is moved.
* Test configuration:
MCU: PIC16F887
Dev.Board: EasyPIC5
Oscillator: HS, 08.0000 MHz
Ext. Modules: LCD 2x16
SW: mikroC PRO for PIC
* NOTES:
- Turn on LCD backlight switch (SW9.7) on development board.(board specific)
*/

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

char txt1[] = "mikroElektronika";
char txt2[] = "EasyPIC5";
char txt3[] = "Lcd4bit";
char txt4[] = "example";

char i; // Loop variable

void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}

void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt3); // Write text in first row

Lcd_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,5,txt2); // Write text in second row

Delay_ms(2000);

// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}

while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}

for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}
 
hi! in our project we had 20*4 lcd display,we used lcd just to display few characters.our code was also written in microC,i am giving you some part of it below,see if it is helpful to you--
we had written separate display function--


void display(unsigned short cursor,const char *dis)
{
LCD_Cmd(cursor);
while(*dis)
{
LCD_Chr_Cp(*dis++)
}
}


at the beginning of code we had list of whatever we wanted to display on LCD
e.g. const char menu_00[]="WELCOME";


and in main program lines related to lcd were as follows--

void main()
{

LCD_Init(&PORTB); //initialize lcd on portb
LCD_Cmd(LCD_CLEAR); //clear lcd display
display(LCD_second_ROW+7,menu_00); //display WELCOME

}

---------- Post added at 12:26 ---------- Previous post was at 12:18 ----------

we had used PIC 18F4520
 
Hi,
This is a code using mikroC v8.2. I've attached the hex and Proteus DSN file. Try with the hex file (clock = 4MHz) and let us know if it works.
Code:
void main(void){
     LCD_Init(&PORTB);
     LCD_Cmd(Lcd_CLEAR);       // Clear display
     LCD_Cmd(Lcd_CURSOR_OFF);  // Turn cursor off
     LCD_Out(1, 1, "Hello");      // Print text to LCD, 2nd row, 1st column
     while (1);
}

Hope this helps.
Tahmid.
 

Attachments

  • LCD TEST mikroC.zip
    6.3 KB · Views: 198
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top