TheKnightRider
Newbie level 2
- Joined
- Jan 27, 2011
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,313
Hello,
I am a beginner with 8051 family. I am trying to implement serial communication using 89S52 with PC. The string (rather a singel chracter at this stage) will be transmitted through Hyperterminal and after reception the received text (what ever it be) has to be displayed on LCD. The problem is when I am debugging the code in keil, it's showing proper output i.e. the values at the lcd port are proper ASCII values of particular chracter being entered. But when it comes to hardware, the LCD is showing chracters that seems like those sent by aliens. I am progisp for burning the code, and a kit from HPS electronics. The code i am usin g is as follows:
The reason behind introducing so many delays is I thought their may be some latency. Please help.
I am a beginner with 8051 family. I am trying to implement serial communication using 89S52 with PC. The string (rather a singel chracter at this stage) will be transmitted through Hyperterminal and after reception the received text (what ever it be) has to be displayed on LCD. The problem is when I am debugging the code in keil, it's showing proper output i.e. the values at the lcd port are proper ASCII values of particular chracter being entered. But when it comes to hardware, the LCD is showing chracters that seems like those sent by aliens. I am progisp for burning the code, and a kit from HPS electronics. The code i am usin g is as follows:
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 #include <REGX52.H> sbit rs= P2^0; sbit rw= P2^1; sbit en= P2^2; void msdelay(unsigned int itime) { unsigned int i,j; for(i=0;i<itime;i++) for(j=0;j<1275;j++); } void lcdcmd(unsigned char value) { P1=value; msdelay(5); rs=0; msdelay(5); rw=0; msdelay(5); en=1; msdelay(5); en=0; } void lcd_data(unsigned char value) { P1=value; msdelay(5); rs=1; msdelay(5); rw=0; msdelay(5); en=1; msdelay(5); en=0; } void uart_init() { TMOD=0x20; TH1=0xFD; SCON=0x50; TR1=1; } void lcd_init() { lcdcmd(0x38); msdelay(10); lcdcmd(0x0E); msdelay(10); lcdcmd(0x01); msdelay(10); lcdcmd(0x06); msdelay(10); lcdcmd(0x80); msdelay(10); } void main() { unsigned char str; unsigned int i; uart_init(); msdelay(250); lcd_init(); msdelay(250); while(1) { while(RI==0); RI=0; str=SBUF; msdelay(250); lcd_data(str); msdelay(250); } }
The reason behind introducing so many delays is I thought their may be some latency. Please help.
Last edited by a moderator: