+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Newbie level 5
    Points: 216, Level: 2

    Join Date
    Mar 2016
    Posts
    10
    Helped
    0 / 0
    Points
    216
    Level
    2

    pic18f452 lcd interfacing problem

    everyone , iam d.a.e student and i prepared for the final year small project called lcd interfacing with pic microcontroller i have write the program and tested in proteus the program work fine but when iam burn it to microcontroller the lcd not show anything can you please check my code and tell me where iam mistaken i use mikroc for pic for program plz replay fast thanxx....


    here is my program...

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
    // LCD module bağlantıları
    sbit LCD_RS at RB2_bit;
    sbit LCD_EN at RB3_bit;
    sbit LCD_D4 at RB4_bit;
    sbit LCD_D5 at RB5_bit;
    sbit LCD_D6 at RB6_bit;
    sbit LCD_D7 at RB7_bit;
     
    sbit LCD_RS_Direction at TRISB2_bit;
    sbit LCD_EN_Direction at TRISB3_bit;
    sbit LCD_D4_Direction at TRISB4_bit;
    sbit LCD_D5_Direction at TRISB5_bit;
    sbit LCD_D6_Direction at TRISB6_bit;
    sbit LCD_D7_Direction at TRISB7_bit;
    // End LCD module bağlantıları
        char i;                              // Loop variable
     
    void Move_Delay() {                  // Function used for text moving
      Delay_ms(50);                     // You can change the moving speed here
    }
     
    void main(){
     
       ADCON1 |= 0x0F;
     
       Lcd_Init();
       Lcd_Cmd(_LCD_CURSOR_OFF);
       Lcd_Cmd(_LCD_CLEAR);
       Lcd_Out(1, 16, "WELCOME TO");
       Lcd_Out(2, 16, "MY PROJECT");
    Last edited by andre_teprom; 18th March 2016 at 18:36. Reason: added C syntax formating

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 4
    Points: 7,943, Level: 21
    Achievements:
    7 years registered
    paulfjujo's Avatar
    Join Date
    Jun 2008
    Location
    France 01120
    Posts
    1,299
    Helped
    263 / 263
    Points
    7,943
    Level
    21

    Re: pic18f452 lcd interfacing problem

    hello,


    for 18F use LAT instead PORT


    1 members found this post helpful.

  3. #3
    Advanced Member level 5
    Points: 8,876, Level: 22
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,568
    Helped
    358 / 358
    Points
    8,876
    Level
    22

    Re: pic18f452 lcd interfacing problem

    add 'while(1);' at the end and check configuration, especially oscillator section
    By the way, it is not 'your' code. You did simply copied it from example.
    Love me or hate me. All infractions will be ignored.


    1 members found this post helpful.

  4. #4
    Super Moderator
    Points: 28,512, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,475
    Helped
    1078 / 1078
    Points
    28,512
    Level
    41
    Blog Entries
    6

    Re: pic18f452 lcd interfacing problem

    Assuming that the circuit was correctly assembled as well as you have not problem in hardware ( e.g contrast pin of LCD not properly biased ), the next step should you add directives to preset on code the configuration bits exactly as you defined on Proteus.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  5. #5
    Full Member level 5
    Points: 2,650, Level: 11
    Achievements:
    Created Album pictures 7 years registered
    malik_zohaib's Avatar
    Join Date
    Sep 2010
    Location
    Pakistan
    Posts
    261
    Helped
    36 / 36
    Points
    2,650
    Level
    11

    Re: pic18f452 lcd interfacing problem

    Your code is not complete; Go to Mikro C help and you'll find the lcd interfacing code example.


    1 members found this post helpful.

  6. #6
    Newbie level 5
    Points: 216, Level: 2

    Join Date
    Mar 2016
    Posts
    10
    Helped
    0 / 0
    Points
    216
    Level
    2
    thanx for all for fast reply iam A bit confused can someone tell me which oscillator i should used for pic18f during burn hex file ,,,iam using picpgm tool for burn but when i goes to configuration bit tab there are more then one oscillator OPTIONS which i don' understand that which one i have to use in configuration bit tab of picpgm tool. plz tell me which one i have to use


    RC oscillator
    HS OSCILLATOR
    XT OSCILLATOR



    WHICH OSCILLATOR I SHOULD USED xt ,,hs,, or rc

    - - - Updated - - -

    thanx sir can you check my code and tell me where i mistaken actualy sir i have left just one week to complete my project and i can't understand why it's not working please help me....

    Code:
    // LCD module bağlantıları
    sbit LCD_RS at RB2_bit;
    sbit LCD_EN at RB3_bit;
    sbit LCD_D4 at RB4_bit;
    sbit LCD_D5 at RB5_bit;
    sbit LCD_D6 at RB6_bit;
    sbit LCD_D7 at RB7_bit;
    
    sbit LCD_RS_Direction at TRISB2_bit;
    sbit LCD_EN_Direction at TRISB3_bit;
    sbit LCD_D4_Direction at TRISB4_bit;
    sbit LCD_D5_Direction at TRISB5_bit;
    sbit LCD_D6_Direction at TRISB6_bit;
    sbit LCD_D7_Direction at TRISB7_bit;
    // End LCD module bağlantıları
        char i;                              // Loop variable
    
    void Move_Delay() {                  // Function used for text moving
      Delay_ms(50);                     // You can change the moving speed here
    }
    
    void main(){
    
       ADCON1 |= 0x0F;
    
       Lcd_Init();
       Lcd_Cmd(_LCD_CURSOR_OFF);
       Lcd_Cmd(_LCD_CLEAR);
       Lcd_Out(1, 16, "WELCOME TO");
       Lcd_Out(2, 16, "MY PROJECT");
       
       while(1) {                         // Endless loop
        for(i=0; i<15; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          Delay_ms(500);
          
           while(1) {                         // Endless loop
        for(i=0; i<15; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          
          
          Lcd_Cmd(_LCD_CLEAR);
          
       Lcd_Out(1, 1, "PREPARED BY");
       Lcd_Out(2, 1, "SCIENTIST GROUP");
    
       Delay_ms(1000);
       // Moving text
      for(i=0; i<17; i++) {               // Move text to the right 4 times
        Lcd_Cmd(_LCD_SHIFT_RIGHT);
        Move_Delay();
      }
       Delay_ms(50);
       Lcd_Cmd(_LCD_CLEAR);
    
       Lcd_Out(1, 1, "SAJID SALEEM");
       Lcd_Out(2, 1, "NADEEM SULEMAN");
        Delay_ms(300);
       LCD_CMD(_LCD_TURN_OFF);
       Delay_ms(100);
       LCD_CMD(_LCD_TURN_ON);
       Delay_ms(100);
       LCD_CMD(_LCD_TURN_OFF);
       Delay_ms(100);
       LCD_CMD(_LCD_TURN_OFF);
       Delay_ms(100);
       LCD_CMD(_LCD_TURN_ON);
       Delay_ms(100);
       
       LCD_CMD(_LCD_TURN_OFF);
       Delay_ms(100);
       LCD_CMD(_LCD_TURN_ON);
    
       Delay_ms(2000);
      // Moving text
      for(i=0; i<16; i++) {               // Move text to the right 4 times
        Lcd_Cmd(_LCD_SHIFT_RIGHT);
        Move_Delay();
      }
       Lcd_Cmd(_LCD_CLEAR);
       
       
       Lcd_Out(1, 16, "SPECIAL THANX TO...");
        while(1) {                         // Endless loop
        for(i=0; i<34; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          
        Lcd_Cmd(_LCD_CLEAR);
       
       Lcd_out(1,16, "Junaid Zaheer &");
       Lcd_out(2,16, "MY ALL TEACHERS");
        while(1) {                         // Endless loop
        for(i=0; i<15; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          Delay_ms(2000);
          
          while(1) {                         // Endless loop
        for(i=0; i<15; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          Lcd_Cmd(_LCD_CLEAR);
          
          Lcd_out(1,1, "THANKS FOR");
          Lcd_out(2,1, "WATCHING.......");
          Delay_ms(2000);
          
          while(1) {                         // Endless loop
        for(i=0; i<17; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          Lcd_Cmd(_LCD_CLEAR);
          
        Lcd_out(1,16, "CODE IS WRITTEN BY.....");
          
           while(1) {                         // Endless loop
         for(i=0; i<35; i++) {             // Move text to the left 7 times
          Lcd_Cmd(_LCD_SHIFT_LEFT);
          Move_Delay();}
          Lcd_Cmd(_LCD_CLEAR);
      
          
     
    }}}}}} }  }
    Last edited by betwixt; 19th March 2016 at 09:38. Reason: added code tags



  7. #7
    Super Moderator
    Points: 76,741, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,548
    Helped
    4183 / 4183
    Points
    76,741
    Level
    67

    Re: pic18f452 lcd interfacing problem

    Use RC if you are using an external resistor and capacitor to set the clock frequency - not accurate but cheap.
    Use XT for quartz crystals or ceramic resonators up to about 4MHZ.
    Use HS for higher frequency crystals and resonators.

    The only difference between XT and HS is the gain of the amplifier in the intenal oscillator is changed so there is an area of say 3.5MHz to 4.5MHz where both modes will work equally well.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  8. #8
    Advanced Member level 1
    Points: 3,498, Level: 13

    Join Date
    May 2012
    Posts
    480
    Helped
    112 / 112
    Points
    3,498
    Level
    13

    Re: pic18f452 lcd interfacing problem

    Ensure the MCLR pin is tied or pulled high
    Ensure that the configuration bits are set correctly (watch dog timer set to off)
    Ensure that the LCD contrast pin is initially connected to ground
    Ensure that you have decoupling capacitors across the supply rails (0.1uf ceramic as close as possible to PIC power connections)
    Check that the oscillator is running.



  9. #9
    Newbie level 5
    Points: 216, Level: 2

    Join Date
    Mar 2016
    Posts
    10
    Helped
    0 / 0
    Points
    216
    Level
    2

    Re: pic18f452 lcd interfacing problem

    yes i did and can someone tell me is this not the oscillator problem i used 20MHZ crystal in proteus simulation and then in the hardware i used 12mhz crystal,,,the question is what will happend if i use lower or greater oscillator ?



    •   AltAdvertisment

        
       

  10. #10
    Advanced Member level 1
    Points: 3,498, Level: 13

    Join Date
    May 2012
    Posts
    480
    Helped
    112 / 112
    Points
    3,498
    Level
    13

    Re: pic18f452 lcd interfacing problem

    A lower frequency oscillator will make the PIC run slower but will make the circuit more likely to work i.e. timings become less critical and the oscillator is more likely to start up. Below 3-4 Mhz you will have to change the oscillator type in the config bits. In a non working circuit like this it is a good idea to run the PIC very slowly to eliminate timing problems (say 1Mhz).
    Last edited by pjmelect; 20th March 2016 at 00:35. Reason: spelling error


    1 members found this post helpful.

--[[ ]]--