EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / why cursor is not moving to next immediate position on LCD 16×2 ( LCD in 4 bit Interface and 2 line)?

why cursor is not moving to next immediate position on LCD 16×2 ( LCD in 4 bit Interface and 2 line)?

|

Microcontroller › PIC › why cursor is not moving to next immediate position on LCD 16×2 ( LCD in 4 bit Interface and 2 line)?

  • This topic has 5 replies, 2 voices, and was last updated 12 years, 8 months ago by siva.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • May 8, 2013 at 1:08 pm #2382
    siva
    Participant

     

    #include<P18f4620.h>  
    #define LCD_RS PORTAbits.RA3 
    #define LCD_RW PORTAbits.RA2 
    #define LCD_EN PORTAbits.RA1 
    void _delay(unsigned int count)
    {
    unsigned int j1,k;
    for(k=0;k<count;k++)
    for(j1=0;j1<900;j1++);
    }
    void lcddata(char dataout) 
    { 
    PORTD = dataout; 
    LCD_RS = 1 ;
    LCD_RW = 0 ;
     
    LCD_EN=1;
    _delay(5);
    LCD_EN=0;
    } 
    void dis_data(char data_value) 
    { 
    char data_value1; 
    data_value1 = ((data_value >> 4) & 0x0F) ; 
    lcddata(data_value1); 
    _delay(2) ; 
    data_value1 = (data_value & 0x0F) ; 
    lcddata(data_value1); 
    _delay(2) ; 
    } 
      
    void lcdcmd(char cmdout) 
    { 
    PORTD=cmdout; 
    LCD_RS = 0 ;
    LCD_RW = 0 ;
    LCD_EN=1;
    _delay(5);
    LCD_EN=0; 
    } 
    void dis_cmd(char cmd_value) 
    { 
    char cmd_value1; 
    cmd_value1 = ((cmd_value >> 4) & 0x0F) ;
    lcdcmd(cmd_value1);
      _delay(2) ; 
    cmd_value1 = (cmd_value & 0x0F) ;
    lcdcmd(cmd_value1);
    _delay(2) ; 
    } 
      
     
    void INIT_LCD(void) 
    { 
    _delay(15) ;
    dis_cmd(0x03);
    _delay(5) ;
    dis_cmd(0x03);
    _delay(1) ;
    dis_cmd(0x03);
    _delay(5); 
    dis_cmd(0x02); 
    _delay(1) ; 
     
    dis_cmd(0x28);
    _delay(1) ;
    dis_cmd(0x08);
    _delay(1) ; 
    dis_cmd(0x01); 
    _delay(2) ;
    dis_cmd(0x06);  
    _delay(1) ;
    dis_cmd(0x0e);
    _delay(1) ;
    dis_cmd(0x80); 
    _delay(1) ; 
    } 
    void INIT_HW(void) 
    { 
    TRISD = 0x00 ; 
    TRISA = 0x00 ;  
    }  
      
     
    void main(void) 
    { 
    unsigned char str_1[12] = “ELECTRONICS” , i=0;
    INIT_HW() ; 
    INIT_LCD() ; 
     
    while(str_1!=0)
    { 
    dis_data(str_1);
    _delay(5) ;
    i++;
    }
    } 
     
      
     
     
     
              we are running the the above code on PICDEM 2 PLUS DEMO BOARD using debugger ICD3 in MPLAB. We observed on lcd the cursor is not going to 81(2nd position in 1st line) from 80 (1st position in 1st line) and it is going to 2nd line from 1st position in 1st line without displaying data.
                If anybody knows please help me. We are doing this one from 1 week.
     
                                                                                        Thank you…………
     
                         
                    
      
    May 9, 2013 at 11:45 am #9689
    siva
    Participant

    pls give me the solution as early as possible

    May 10, 2013 at 7:47 am #9700
    AJISH ALFRED
    Participant

    Hi Siva,

    I think this could be some issues related with pointer access. Try modifying your decleration of array as follows;

    unsigned char *str_1 = “ELECTRONICS”;

    i = 0;

    Befor using any string in your code, Make sure that your ‘dis_data()’ function is working by trying out some random alphabets jsut after INIT_LCD() like,

    dis_data(‘A’);

    dis_data(‘B’);

    May 18, 2013 at 9:58 am #9780
    siva
    Participant

    Sorry ALFRED 

     

     

    in my code PORTA is in analog thats why it has not worked.

    now it is working fine

     

    May 19, 2013 at 5:47 pm #9791
    AJISH ALFRED
    Participant

    Hi Siva,

    Alright, now we just learned one more thing, and that is more important!

    June 12, 2013 at 10:16 am #9952
    siva
    Participant

    k good

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • CR2/CR123A Batteries In Projects February 14, 2026
  • Integrating 0–5V ECU Signals into a Double-DIN Setup – Module vs Custom Head Unit? February 14, 2026
  • Puzzled about a relay February 13, 2026
  • Switch Circut February 13, 2026
  • RC Electronic Speed Control Capacitors February 13, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise