aliraza786
Full Member level 4
- Joined
- Nov 10, 2009
- Messages
- 210
- Helped
- 14
- Reputation
- 28
- Reaction score
- 14
- Trophy points
- 1,298
- Location
- Lahore, Pakistan, Pakistan
- Activity points
- 2,914
hello... i am interfacing LCD with 89c51 and and this uc1 recive data by serial connection... another uc2 send data to uc1 which display on LCD.... but the problem is that when i send data from uc2 to uc1 in this format like "" senddata('A') ''' it display on the lcd connected with uc1 but if i send some value like this,
unsigned char v;
v=5;
senddata(v);
it displays nothing and if i send like this " senddata('v') then it doesnt display 5 but display V......
this is the code of Sending data
________________________________________________________
circuit diagram
---------- Post added at 10:13 ---------- Previous post was at 10:12 ----------
i request to the moderator to tell me how to write code properly
unsigned char v;
v=5;
senddata(v);
it displays nothing and if i send like this " senddata('v') then it doesnt display 5 but display V......
this is the code of Sending data
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 #include<reg51.h> #include<stdlib.h> #include<stdio.h> unsigned char cd[3]; unsigned char a,b,c,e,f,g,sdata1; void send(unsigned char d) { SBUF=d; while(TI==0); TI=0; } void senddata(unsigned char sdata) { if(sdata>=0 && sdata<=9) { send('0'); send('0'); send(sdata); } if(sdata>=10 && sdata<=99) { send(0); a=sdata/10 ; b=sdata%10 ; send(a); send(b); } if(sdata>=100 && sdata<=255) { c=sdata/100; send(c); e=sdata%100; f=e/10; send(f); g=e%10; send(g); } } inits() { TMOD=0x20; TH1=0xFA; SCON=0x50; TR1=1; } void main() { inits(); while(1) { sdata1=P2; senddata(sdata1); } } _______________________________________________________________________ Reciver UC1 code while(1) { for(n=0;n<3;n++) { while(RI==0); mydata=SBUF; lcddata(mydata); RI=0; } lcdcmd(200); for(m=0;m<3;m++) { while(RI==0); mydata=SBUF; lcddata(mydata); RI=0; } m=0; n=0; cpo(136); }
________________________________________________________
circuit diagram
---------- Post added at 10:13 ---------- Previous post was at 10:12 ----------
i request to the moderator to tell me how to write code properly