hi
i want to send a serial data using 89C2051, i got a code from net but its not working
i checked it on Proteus 7 Professional.
how can i send any data or Receive it?
#include "reg51.h" #include "stdio.h" unsigned char a=0; void serial_send(); void main () { TMOD = 0x20; SCON = 0x50; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; P1 = 255; a = 255; while(1) { if (P1 != a) { a = P1; serial_send(); } } } void serial_send() { while(!TI); { TI = 0; SBUF = a; } }
Did it occur to you dear Qazi that your user manual/exaples etc. know? Or the person gave this code snippet? I would not bet my life on it, though...
If you want to do it in 'C', this is a 4-step process:
1. Learn the 'C' programming language
2. Understand the specifics of the Keil C51 implementation
3. Understand the 8051 UART, and how it works.
4. Use all the above to write your own program, or to enable you to understand someone else's program.
Again, you can't skimp on steps 1-3 - you will neither be able to write your own code, nor to understand anyone else's code.
For Step 1, there's a vast wealth of books, sites, and training courses available to help you to learn the 'C' programming language; eg, http://www.keil.com/books/ http://www.keil.com/events/ publications.gbdirect.co.uk/.../ www.eskimo.com/.../
For Step 2, the complete set of Keil manuals - plus application notes and examples - is available here: http://www.keil.com/support/ See also: http://www.keil.com/books/8051books.asp
For Step 3, there's a vast wealth of materials available to help you to learn about the 8051; eg, www.8052.com/.../120112 http://www.8052.com/tutorial http://www.keil.com/books/8051books.asp
And, of course, there are seminars and training courses: http://www.keil.com/events/ http://www.keil.com/events/links.asp
i got a code from net but its not working I lost count how many times I have seen that one.
as I have often stated: ""sample code" can be a time saver if you could code it yourself, if you could NOT code it yourself, you will be totally lost because of the errors in the "sample code", let alone grasping the functionality".
Erik
A 'program' like the above is totally worthless, it does not specify processor ('51 will NOT do) and clock. Let alone publishing uncommented 'code'
Erk