1. Principle of multi-machine communication
Two-to-many machine communication circuit diagram
Here, U1 is the master, U2 is slave 1, and U3 is slave 2.
3. C language program
(1) Host program
#include
#include
#define _SUCC_
#define _ERR_
unsigned char Table[9]={0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
unsigned char Buff[20];
unsigned char temp=0xff;
sbit KEY1=P1^6;
sbit KEY2=P1^7;
//unsigned char addr;
//1ms delay function
void delay_1ms(unsigned int t)
{
}
//Buffer initialization
void Buff_init()
{
}
//Serial port initialization function
void serial_init()
{
}
//Send data function
void SEND_data(unsigned char *Buff)
{
}
//Send data to the specified slave address
void ADDR_data(unsigned addr)
{
}
void main()
{
}[page]
(2) Slave 1 program
#include
#include
#define addr
#define _SUCC_
#define _ERR_
unsigned char aa=0xff; // communication flag between host and slave
unsigned char Buff[20]; // data buffer
//Serial port initialization function
void serial_init()
{
}
//Receive data function
unsigned char RECE_data(unsigned char *Buff)
{
}
void main()
{
}
(3) Slave 2 program
#include
#include
#define addr
#define _SUCC_
#define _ERR_
unsigned char aa=0xff; // communication flag between host and slave
unsigned char Buff[20]; // data buffer
//Serial port initialization function
void serial_init()
{
}
//Receive data function
unsigned char RECE_data(unsigned char *Buff)
{
}
void main()
{
}
Previous article:The importance of variable initialization in multi-machine communication of single-chip microcomputers...
Next article:MRC multiple encryption technology of single chip microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to perform loopback test on Ethernet UDP through DDR3?
- ADI's smoke detector integrated solution based on ADPD188BI live data collection
- What is the use of a 28V operating voltage microcontroller?
- The microcontroller drives the P-MOS to conduct abnormally through the NPN transistor?
- How to support domestic suppliers who use tricks?
- Thank you for being there + seeking change
- RVB2601 First Experience
- If the Lingte LT3789 is to output 12V10A, can it be directly connected in parallel with MOS?
- MSP430 and ATK-NEO-6M GPS module
- Saw a picture on the official account