Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 embedded code 4 serial comm

Status
Not open for further replies.

akashexe

Newbie level 3
Joined
Jul 22, 2006
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
can some one give a code to transmit a byte over the rs232 cable thru the port 0 of 8051.
 

well i wanted seperate code to transmit and receive data byte from rs 232 cable
the programming languauge that i expected is embedded c
 

whatz the purpose? when u have on board uart hardware. ok anyway, configure one timer for the required baud rate, now send a bit(LS, stop bit first) and read the val on receiving port. remember to connect max232 level shifter.
 

Look at this file.
 

If you use Keil C51, what do you need is call this function :

Code:
void initUART(void) {
    SCON=0x53;  //serial port as regular UART
    TH1=0xFD;   //9600 baud with 11.059 MHz xtal
    TL1=0xFD;
    TR1=1;      //start baid rate generator
}

after that you can use these function to do serial I/O :

Code:
// serial character input function
char getchar(void);            

// serial character output function
void putchar(char c);          

// serial string output function
void puts(const char *string); 

// serial string input function
char *gets (char *string,     /* string to read             */
            int len);         /* maximum characters to read */

Note : read C:\Keil\C51\HLP\C51lib.chm for more information and samples
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top