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 11 years, 7 months ago by siva.
Viewing 6 posts - 1 through 6 (of 6 total)
-
AuthorPosts
-
May 8, 2013 at 1:08 pm #2382sivaParticipant#include<P18f4620.h>#define LCD_RS PORTAbits.RA3#define LCD_RW PORTAbits.RA2#define LCD_EN PORTAbits.RA1void _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 #9689sivaParticipant
pls give me the solution as early as possible
May 10, 2013 at 7:47 am #9700AJISH ALFREDParticipantHi 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 #9780sivaParticipantSorry 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 #9791AJISH ALFREDParticipantHi Siva,
Alright, now we just learned one more thing, and that is more important!
June 12, 2013 at 10:16 am #9952sivaParticipantk good
-
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.