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; }
View all questions in Keil forum