+ Post New Thread
Results 1 to 15 of 15
  1. #1
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    problem with mikroc programing lcd code - can any one help me

    how can i send text to the lcd in the mikroc
    i use mikroc pro

    Code:
    // LCD module connections
    sbit LCD_RS at RB0_bit;
    sbit LCD_EN at RB1_bit;
    sbit LCD_D4 at RB2_bit;
    sbit LCD_D5 at RB3_bit;
    sbit LCD_D6 at RB4_bit;
    sbit LCD_D7 at RB5_bit;
    
    sbit LCD_RS_Direction at TRISB0_bit;
    sbit LCD_EN_Direction at TRISB1_bit;
    sbit LCD_D4_Direction at TRISB2_bit;
    sbit LCD_D5_Direction at TRISB3_bit;
    sbit LCD_D6_Direction at TRISB4_bit;
    sbit LCD_D7_Direction at TRISB5_bit;
    // End LCD module connections
    
    
    
    void main()
    {
    
    Lcd_Init();
    Lcd_Cmd(_LCD_TURN_ON); // Clear the LCD
    //Lcd_Out(1,4,"My Computer");
    Lcd_Out_Cp("Here!");
    Delay_ms(500);
    Lcd_Cmd(_LCD_TURN_OFF); // Clear the LCD
    
    }
    - - - Updated - - -

    is the problem in the code or in the compiler ?

  2. #2
    Advanced Member level 1
    Points: 4,245, Level: 15
    Achievements:
    7 years registered
    hexreader's Avatar
    Join Date
    Apr 2011
    Location
    England
    Posts
    483
    Helped
    188 / 188
    Points
    4,245
    Level
    15

    Re: problem with mikroc programing lcd code - can any one help me

    Quote Originally Posted by eng_msa_8_8 View Post
    is the problem in the code or in the compiler ?
    Code.

    LCD library requires that you use LAT registers with PIC18 outputs, like this:

    Code:
    // LCD module connections
    sbit LCD_RS at LATB0_bit;
    sbit LCD_EN at LATB1_bit;
    sbit LCD_D4 at LATB2_bit;
    sbit LCD_D5 at LATB3_bit;
    sbit LCD_D6 at LATB4_bit;
    sbit LCD_D7 at LATB5_bit;
    
    sbit LCD_RS_Direction at TRISB0_bit;
    sbit LCD_EN_Direction at TRISB1_bit;
    sbit LCD_D4_Direction at TRISB2_bit;
    sbit LCD_D5_Direction at TRISB3_bit;
    sbit LCD_D6_Direction at TRISB4_bit;
    sbit LCD_D7_Direction at TRISB5_bit;
    // End LCD module connections
    
    
    
    void main()
    {
    
        Lcd_Init();
        Lcd_Cmd(_LCD_TURN_ON);                   // Clear the LCD ? don't think it does - try (_LCD_CLEAR)
        //Lcd_Out(1,4,"My Computer");
        Lcd_Out_Cp("Here!");
        Delay_ms(500);
        Lcd_Cmd(_LCD_TURN_OFF);                 // Clear the LCD
    
    }


    1 members found this post helpful.

  3. #3
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    no output
    the screen lights up but no litters

    plz try to compile it and send hex file to try it

    - - - Updated - - -

    i use that code

    Code:
    // LCD module connections
    sbit LCD_RS at LATB0_bit;
    sbit LCD_EN at LATB1_bit;
    sbit LCD_D4 at LATB2_bit;
    sbit LCD_D5 at LATB3_bit;
    sbit LCD_D6 at LATB4_bit;
    sbit LCD_D7 at LATB5_bit;
    
    sbit LCD_RS_Direction at TRISB0_bit;
    sbit LCD_EN_Direction at TRISB1_bit;
    sbit LCD_D4_Direction at TRISB2_bit;
    sbit LCD_D5_Direction at TRISB3_bit;
    sbit LCD_D6_Direction at TRISB4_bit;
    sbit LCD_D7_Direction at TRISB5_bit;
    // End LCD module connections
    
    
    
    void main()
    {
    
        Lcd_Init();
        Lcd_Cmd(_LCD_TURN_ON);                   // Clear the LCD ? don't think it does - try (_LCD_CLEAR)
        Lcd_Cmd(_LCD_CLEAR);
        //Lcd_Out(1,4,"My Computer");
        Lcd_Out_Cp("Here!");
        Delay_ms(500);
        Lcd_Cmd(_LCD_TURN_OFF);                 // Clear the LCD
    
    }



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 1
    Points: 4,245, Level: 15
    Achievements:
    7 years registered
    hexreader's Avatar
    Join Date
    Apr 2011
    Location
    England
    Posts
    483
    Helped
    188 / 188
    Points
    4,245
    Level
    15

    Re: problem with mikroc programing lcd code - can any one help me

    Full project attached. Works for me, latest compiler version, real hardware. 8MHz crystal with 2x22pF caps.

    500mS is not very long though, you need to watch the display very carefully or you will miss it.



  5. #5
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    also ur hex file didnt work in my proteus

    do u saw my circuit ?



    •   AltAdvertisment

        
       

  6. #6
    Advanced Member level 1
    Points: 4,245, Level: 15
    Achievements:
    7 years registered
    hexreader's Avatar
    Join Date
    Apr 2011
    Location
    England
    Posts
    483
    Helped
    188 / 188
    Points
    4,245
    Level
    15

    Re: problem with mikroc programing lcd code - can any one help me

    Quote Originally Posted by eng_msa_8_8 View Post
    do u saw my circuit ?
    Ah... I see what you mean....

    PIC18F452 requires an external clock circuit of some kind. No wonder that it does not work. Your circuit is no good.

    Read the PIC datasheet to find out what kind of clock circuit is needed.



    •   AltAdvertisment

        
       

  7. #7
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    the clock is programed in the pic ship window
    i selected it as 4Mhz

    when i do another codes for led as example it works without external clock


    so where is the problem ?



  8. #8
    Advanced Member level 1
    Points: 4,245, Level: 15
    Achievements:
    7 years registered
    hexreader's Avatar
    Join Date
    Apr 2011
    Location
    England
    Posts
    483
    Helped
    188 / 188
    Points
    4,245
    Level
    15

    Re: problem with mikroc programing lcd code - can any one help me

    Quote Originally Posted by eng_msa_8_8 View Post
    the clock is programed in the pic ship window
    i selected it as 4Mhz

    when i do another codes for led as example it works without external clock


    so where is the problem ?
    You need to connect R/W pin of both LCD displays to 0 Volts



  9. #9
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    here is some errors
    proteus alert me


    and ther is another project it works without external clock

    - - - Updated - - -

    i also in the picture i conected w/r to gnd



  10. #10
    Newbie level 2
    Points: 34, Level: 1

    Join Date
    Oct 2012
    Posts
    2
    Helped
    0 / 0
    Points
    34
    Level
    1

    Re: problem with mikroc programing lcd code - can any one help me

    i think you must set initial value of inputs & outputs zeroes .



  11. #11
    Advanced Member level 1
    Points: 4,245, Level: 15
    Achievements:
    7 years registered
    hexreader's Avatar
    Join Date
    Apr 2011
    Location
    England
    Posts
    483
    Helped
    188 / 188
    Points
    4,245
    Level
    15

    Re: problem with mikroc programing lcd code - can any one help me

    Here is a version built for 4MHz clock and without turning off the display.

    Works on real hardware, but no idea whether it will work with Proteus.

    EDIT: ... just noticed .... your original circuit diagram would normally have MCLR connected to a 10K resistor, with the other side of the resistor connected to +5V.
    Also LCD2 should have Vee connected to ground, not to +5V, though Proteus probably would not care.
    Last edited by hexreader; 21st October 2012 at 20:08.



  12. #12
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    HOW ?
    plz explain more

    - - - Updated - - -

    Quote Originally Posted by hexreader View Post
    Here is a version built for 4MHz clock and without turning off the display.

    Works on real hardware, but no idea whether it will work with Proteus.

    EDIT: ... just noticed .... your original circuit diagram would normally have MCLR connected to a 10K resistor, with the other side of the resistor connected to +5V.
    Also LCD2 should have Vee connected to ground, not to +5V, though Proteus probably would not care.
    what is the meaning of
    "hd44780 controller received data whilst busy"



  13. #13
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    in my circuit i didnt use hd44780



    •   AltAdvertisment

        
       

  14. #14
    Junior Member level 3
    Points: 793, Level: 6

    Join Date
    Jun 2009
    Posts
    27
    Helped
    0 / 0
    Points
    793
    Level
    6

    Re: problem with mikroc programing lcd code - can any one help me

    so no help !?



  15. #15
    Banned
    Points: 6,265, Level: 18

    Join Date
    Jul 2012
    Posts
    1,192
    Helped
    172 / 172
    Points
    6,265
    Level
    18

    Re: problem with mikroc programing lcd code - can any one help me

    Before LCD_init(); command add these lines.

    Code:
    TRISB = 0x00;
    PORTB = 0x00;
    and remove this line

    Code:
    Lcd_Cmd(_LCD_TURN_OFF); // Clear the LCD
    otherwise the text will be displayed and then the lcd will turn off. It will happen so fast that you will only see blank lcd.

    In Proteus some LCDs are considered HD44780 compatible and hence programmed as HD44780 based LCD.
    Last edited by internetuser2k12; 23rd October 2012 at 07:15.



--[[ ]]--