+ Reply to Thread
Results 1 to 6 of 6

Thread: pic 18f4550 lcd interfacing

  1. #1
    venugopal Newbie
    Join Date
    Mar 2009
    Posts
    2

    pic 18f4550 lcd interfacing

    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

    }//~!


  2. #2
    I <3 electronics edeca Excellent edeca Excellent edeca Excellent edeca Excellent edeca Excellent
    Join Date
    Apr 2008
    Location
    England
    Posts
    261

    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.

  3. #3
    arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent arhi Excellent
    Join Date
    Apr 2008
    Location
    Belgrade, .rs
    Posts
    832

    the code is ok
    the possible problems are
    1. configuration. are you sure you set config bits properly
    2. hw setup, did you connect the lcd same way you configured the lcd function (B7-B4 for DATA, B2.3.4 for control)

  4. #4
    venugopal Newbie
    Join Date
    Mar 2009
    Posts
    2

    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?.

  5. #5
    five0 Newbie
    Join Date
    Dec 2007
    Posts
    19

    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

  6. #6
    Peca Newbie
    Join Date
    Jan 2009
    Location
    Belgrade, Serbia
    Posts
    21

    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)
    Attached Images
    Last edited by Peca; 28th March 2009 at 02:38 PM.

+ Reply to Thread

Similar Threads

  1. USB - First try - PIC 18F4550
    By atferrari in forum Micro Controllers
    Replies: 8
    Latest: 28th April 2008, 11:48 AM
  2. Pic 18f4550
    By watzmann in forum Micro Controllers
    Replies: 3
    Latest: 29th February 2008, 06:19 PM
  3. 18f4550 RC0
    By HerbertMunch in forum Micro Controllers
    Replies: 2
    Latest: 19th February 2008, 11:59 AM
  4. plz help on pic 18f4550
    By shetti.umesh in forum Electronic Projects Design/Ideas/Reviews
    Replies: 1
    Latest: 9th February 2007, 05:50 AM
  5. Pic 18f4550 & VB6
    By lentz in forum Micro Controllers
    Replies: 0
    Latest: 7th March 2006, 07:24 PM

Tags for this Thread