Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic 18f4550 lcd interfacing

Status
Not open for further replies.

venugopal

New Member
Hi all,I am new to this forum.I interfaced pic18f4550 microcontroler to lcd ,I wrote the c program and compiled it in mikro c compiler.The code I compiled was example provided by mikroc. it was actually written for pic18f8520 I changed to 18f4550 in the project window.the problem is, i am not getting anything on the screen.can anyone help to solve this problem?
The oscillator used is crystal 8Mhz
trim pot 5k to contrast change.
lcd(16*2 display) similar to hd44780,it has 8 data bits d0 to d7,vcc,vss,backlight led all similar to hd44780.
The c program is below


/*
* Project name:
Lcd_Test (Simple demonstration of the LCD Library functions)
* Copyright:
(c) MikroElektronika, 2005.
* Description:
This is a simple demonstration of LCD library functions. LCD is first
initialized (PORTB, 4-bit data interface, default pin settings), then some
text is written at the first row.
* Test configuration:
MCU: P18F8520
Dev.Board: BIGPIC4
Oscillator: HS, 10.0 MHz
Ext. Modules: LCD
SW: mikroC v8.0
* NOTES:
None.
*/

char *text = "mikroC_123";

void main() {
unsigned short btnRes;

CMCON |= 0x07; // turn off comparators
ADCON1 |= 0x0F; // turn off analog input // disable external memory bus

Lcd_Custom_Config(&PORTb, 7,6,5,4,&PORTb, 2,4,3); // Initialize LCD connected to PORTH
Lcd_Custom_Cmd(LCD_CLEAR); // Clear display
Lcd_Custom_Cmd(LCD_CURSOR_OFF); // Turn cursor off
Lcd_Custom_Out(1,1, text); // Print text to LCD, 2nd row, 1st column
Lcd_Custom_Chr_CP('@');
Lcd_Custom_Chr(1,14, '#');
Lcd_Custom_Cmd(LCD_SECOND_ROW);
Lcd_Custom_Out_CP(text);

while (1) ; // endless loop

}//~!
 
Compile your code and load the hex into the Oshonsoft simulator. If that works then you most likely have a hardware problem.

The example you have looks like it uses a 4 bit interface. At a guess (I don't have mikroC) it is using RB7/6/5/4 for the data and RB2/4/3 for the 3 control pins. A diagram of how you have wired it would help.
 
pic18f4550 lcd interfacing

thanks for your support.

I checked the connections but still i am not getting any display except few black blocks on right side of the lcd display when I varied potentiometer to give max. resistance.

I downloaded Oshonsoft simulator and tried it took more than ahour and displayed nothing on lcd simulator.Am I doing any mistake here ?

one boubt I am having is that above example is for pic18f8520 which is a 80 pin microcontroller,I just set to pic18f4550,8Mhz in project window.so will the program written for 80 pin when converted to 40 pin pic will we get output successfully ? can you tell whats wrong I am doing here?.
 
I don't use MikroC, but your control and data had same pin (4), so when data change the control also change, result Lcd don't know what to do.
just try change control pin(4) to 1
Lcd_Custom_Config(&PORTb, 7,6,5,4,&PORTb, 2,4,3); // Initialize LCD
 
Hi,

look at the given code - use Mikroelektronika`s LCD library for 2x16 text display (included in meny Tools). I have EasyPIC3 at 8MHz with the PIC18F4550 and this library works fine. Also, turn OFF the watchdog!
Use Lcd_Init for default pin settings (see the first figure below).

char *text = "mikroElektronika";

void main() {
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 1, text); // Print text to LCD, 2nd row, 1st column
}//~!

LCD HW connection by default initialization (using Lcd_Init)
 

Attachments

  • easypic3_manual.jpg
    easypic3_manual.jpg
    40.6 KB · Views: 1,628
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top