Greeting everyone
Do you know any good tutorial for me to learn how to set up a serial communication between two AT89C51 chips in C language and a schematic layout?
Thank in advance
Maverickmax
Greeting everyone
Do you know any good tutorial for me to learn how to set up a serial communication between two AT89C51 chips in C language and a schematic layout?
Thank in advance
Maverickmax
To connect 2 51 microcontrollers you even dont need drivers (unless they are some distance apart). Just connect Rx os the first on with Tx of the second one and Tx of the first one with Rx of the second one + Common GND and your hardware is ready.
You will have to set-up boyh UART for the same baud-rate and configuration.
Other thing to consider is the use of serial port interrupts.
Another issue is the use of command-response protocol but this may put one controller in MASTER position and the other in SLAVE.
Oic.....
I will do that but can you please tell me more about serial interrupt port?
Is there any C programs for transmitting data between two devices?
Maverickmax
I am kind of struck at the moment because I am not sure how to transmit data from 8051 chip to another.
Please advise or give me some links
Maverickmax
Hi Maverickmax,
Your question has an complete answer in the book
"Patterns for time triggered Embedded systems" by M. J. Pont
(for 8051 micros)
in chapter 27 is presented a complete solution
One uC is declared master, and others are declared slaves.
Master emit 9 bit messages: 8bits=data (or adress for the selected slave)
Distinction between 8 bit data or 8bit adress of the slave is made by the 9'th bit emited by the master
UART is in mode 3 for both masters and slaves
Unfortunately an eletronic version of the "bible" doesn't exist , anyway here is some sample code in C (K*il) to get a fillng:
SCU_Am.c master
SCU_As.c slave software
Hi
I would find the master and slave in the scheduler approach very useful for my future project but I only want to send data across to another AT89C51 (Receiver) in one way mode via wire.
For example, the first AT89C51 is designed to send a temperature reading across the wire to another AT89C51. That's it
Maverickmax
Check attached file. You should use function UART_CommInit to initialize once every of two uC UARTs. Then one uC can use function UART_Putchar to send single char to another uC. And second uC will use UART_Getchar to receive this char. Also, to send more than one char you can use function UART_Printf.Originally Posted by Maverickmax
This small UART lib is interrupt-driven with send/receive buffers, so you don't have to worry to check state of UART before sending/receiving new char. Buffer size is defined by TBUF_SIZE constant.
Good luck!
hi ;
i have made a serial communication between 89c2051 and 89c51 ,
but i didn't get a good results ,
i guessed it is because of their ossilators are seprate , i mean sender may change data when receiver is sampling input , so an invalid data whould be received ,
i at last wrote a program using 2 input/output pin for serial communication , but this way it was too slower than a ready UART .
i have talked about this problem in :
http://www.edaboard.com/viewtopic.ph...hlight=#316254
UART uses an asynchronous protocol, so separate oscillators have nothing related to your problem and you should search for bug in your program, especially in initialization procedure.Originally Posted by hm_fa_da