Jul 8, 2011 #1 N Naman100 Newbie level 2 Joined Jul 8, 2011 Messages 2 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,283 Activity points 1,298 Hi everyone, I am trying to run 16x2 lcd with lpc 2148 on proteus.I was successful in running the lcd when i used 8 bit mode but when im using 4 bit mode,nothing is getting displayed on the lcd except moving cursor..Please help.Thanx in advance.. Im posting my code below.. 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #include <LPC214x.h> void cmd(unsigned char d); void datal(unsigned char t); void delay (int count); int main() { int i; unsigned char name[]={"Naman"}; IO0DIR=0x0003F400; //0b0000 0000 0000 0011 1111 0100 0000 0000 delay(100); cmd(0x28); cmd(0x01); cmd(0x02); cmd(0x06); cmd(0x0e); for (i=0;i<5;i++) { datal(name[i]); } while(1); } void cmd(unsigned char d) { int a=0; a=(d>>4) & 0x0F; a=a<<14; IO0CLR = 0x00003000; IO0SET = 0x00000400; IO0CLR = 0x0003C000; IO0SET = a; delay(1000); IO0CLR = 0x00000400; a=d & 0x0F; a=a<<14; IO0CLR = 0x00003000; IO0SET = 0x00000400; IO0CLR = 0x0003C000; IO0SET = a; delay(1000); IO0CLR = 0x00000400; } void datal(unsigned char t) { int b=0; b= (t>>4)&0x0F; b=b<<14; IO0SET = 0x00002400; IO0CLR = 0x0003C000; IO0SET = b; delay(1000); IO0CLR = 0x00000400; b=t&0x0F; b=b<<14; IO0SET = 0x00002400; IO0CLR = 0x0003C000; IO0SET = b; delay(1000); IO0CLR = 0x00000400; } void delay(int count) { int j=0, i=0; for (j=0;j<count;j++) for (i=0;i<35;i++); }
Hi everyone, I am trying to run 16x2 lcd with lpc 2148 on proteus.I was successful in running the lcd when i used 8 bit mode but when im using 4 bit mode,nothing is getting displayed on the lcd except moving cursor..Please help.Thanx in advance.. Im posting my code below.. 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #include <LPC214x.h> void cmd(unsigned char d); void datal(unsigned char t); void delay (int count); int main() { int i; unsigned char name[]={"Naman"}; IO0DIR=0x0003F400; //0b0000 0000 0000 0011 1111 0100 0000 0000 delay(100); cmd(0x28); cmd(0x01); cmd(0x02); cmd(0x06); cmd(0x0e); for (i=0;i<5;i++) { datal(name[i]); } while(1); } void cmd(unsigned char d) { int a=0; a=(d>>4) & 0x0F; a=a<<14; IO0CLR = 0x00003000; IO0SET = 0x00000400; IO0CLR = 0x0003C000; IO0SET = a; delay(1000); IO0CLR = 0x00000400; a=d & 0x0F; a=a<<14; IO0CLR = 0x00003000; IO0SET = 0x00000400; IO0CLR = 0x0003C000; IO0SET = a; delay(1000); IO0CLR = 0x00000400; } void datal(unsigned char t) { int b=0; b= (t>>4)&0x0F; b=b<<14; IO0SET = 0x00002400; IO0CLR = 0x0003C000; IO0SET = b; delay(1000); IO0CLR = 0x00000400; b=t&0x0F; b=b<<14; IO0SET = 0x00002400; IO0CLR = 0x0003C000; IO0SET = b; delay(1000); IO0CLR = 0x00000400; } void delay(int count) { int j=0, i=0; for (j=0;j<count;j++) for (i=0;i<35;i++); }
Jul 14, 2011 #2 J john blue Advanced Member level 3 Joined Jun 7, 2007 Messages 821 Helped 213 Reputation 430 Reaction score 204 Trophy points 1,323 Activity points 4,749 Try to look for the 4bit LCD power up sequence. It is a bit different from 8 bit
Jul 14, 2011 #3 N Naman100 Newbie level 2 Joined Jul 8, 2011 Messages 2 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,283 Activity points 1,298 It is working now.. d problem was that cmd(0x02) should be written before cmd(0x28). Thank you, Naman
It is working now.. d problem was that cmd(0x02) should be written before cmd(0x28). Thank you, Naman