I need some help regarding how to give input through serial port. I can see the output of serial port in UART #1.
char rxcharacter(void) { char character;
SBUF = _getkey (); //SBUF = 'G';
while(RI != 1);
character = SBUF; RI = 0;
return character; }
This is my source. I am very new to this tool. Please let me know how give input from a serial port.
#include <stdio.h> #include <reg51.h>
void txcharacter(char character); char rxcharacter(void);
main(){
unsigned char character;
SCON = 0x10; /* recieve enabled mode 0 ---> 8-bit shift register with baud rate = 1MHz */
TI = 1; // you can now transmit on the line
while(1){
character = rxcharacter();
txcharacter(character); } }
void txcharacter( char character) {
while(TI != 1); TI = 0; SBUF = character; return; }
Do you mean you are just new to the Keil tools, or also new to the 8051?
Do you have any general 'C' experience?
For Keil details, study the Manuals: http://www.keil.com/support/man_c51.htm
In particular, http://www.keil.com/support/man/docs/uv4/uv4_examples.htm
See also: http://www.keil.com/books/
For the 8051 in general, see:
http://www.8052.com/tutorial
www.8052.com/.../120112
http://www.keil.com/books/8051books.asp
For general starting with 'C', see: blog.antronics.co.uk/.../
SCON = 0x10; /* recieve enabled mode 0 ---> 8-bit shift register with baud rate = 1MHz */ the validity of the above will depend on 1) clock speed 2) derivative
Erik
Very new to keil tool and 8051.
But I have some C experience.
thanks for the links.
i am using 8051AH. crystal frequency = 12MHz
As SM0 = 0 and SM1 = 0 ---> serial mode 0 ===> it will work as a 8 bit shift register with a baud rate = 12MHz /12 = 1MHz
You are saying my baud rate is very high?
View all questions in Keil forum