Serial communication program for two 51 single-chip microcomputers to communicate with each other

Publisher:bln898Latest update time:2015-10-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;The system crystal is 11.0592 MHz

;51 MCU sends MCU program
; this program is simulated by Proteus

;This program has been tested on hardware
; 2007-05-27
; A simplified circuit diagram is attached
; In order to make it easier for beginners to understand, the program and diagram are as simple and concise as possible

;The experimental phenomenon is that which key of the P1 port of the transmitter is connected, and which light of the receiver is lit
; If the T and R of the two microcontrollers are expanded through a wireless module (such as a module based on the MCP2120 chip), wireless communication can be achieved.
                    ORG                  0000H
                    AJMP                 START
                    ORG                  0040H
START:
                    MOV                  SP,#60H        
                    MOV                  SCON,#50H                    ;Serial port mode 1
                    MOV                  TMOD,#20H                    ;T1 mode 2

                    MOV                  TL1,#0FDH                    ; constant of baud rate 9600
                    MOV                  TH1,#0FDH
                    SETB                 TR1   
                    mov                  r5,#00h                    
WAIT:
                    mov                p1,#0ffh
                    mov                a ,p1
                    mov                r5,a
                    lcall delay                       ; read keyboard, remove jitter here, and add a few words
                    mov                a ,p1
                     nop
                    CJNE                 A,5,WAIT                 ; whether there is key input
                    MOV                  SBUF,a                       ; serial port outputs the value of keyboard input
                    NOP
SS:                  JBC                  TI,WAIT                      ; whether the sending is completed
                    SJMP                 SS
DELAY:                                       ; delay subroutine
                    PUSH                 0                            ; save the scene
                    PUSH                 1
                    MOV                  0,#06H
DELAY1: MOV                  1,#0H
                    DJNZ                 1,$
                    DJNZ                 0,DELAY1
                    POP                  1                            ; restore the scene
                    POP                  0
                    RET
                    END

Serial communication program for two 51 microcontrollers to communicate with each other (one sending program and one receiving program)

 

;The system crystal oscillator is 11.0592 MHz
;51 MCU receives the MCU program
;This program is simulated by Proteus

;This program has been tested on hardware
; 2007-05-27
; A simplified circuit diagram is attached
; In order to make it easier for beginners to understand, the program and diagram are as simple and concise as possible

;The experimental phenomenon is that which key of the P1 port of the transmitter is connected, and which light of the receiver is lit
; If the T and R of the two microcontrollers are expanded through a wireless module (such as a module based on the MCP2120 chip), wireless communication can be achieved.
                    ORG                  0000H
                    AJMP                 START
                    ORG                  0040H
START:        
                    MOV                  SCON,#50H                    ;Serial port mode 1
                    MOV                  TMOD,#20H                    ;T1 mode 2

                    MOV                  TL1,#0FDH                    ; constant of baud rate 9600
                    MOV                  TH1,#0FDH
                    SETB                 TR1           
                   WAIT:
                    JBC                  RI,DIS_REC                   ; whether data is received        
                    sjmp                 wait
DIS_REC:
                    MOV                  A,SBUF                       ; read the data received by the serial port         
                    mov                  p1,a
                    SJMP                 wait
                    end

Reference address:Serial communication program for two 51 single-chip microcomputers to communicate with each other

Previous article:The high four bits of the microcontroller P1 port are used as buttons, and the low four bits are used as output display program
Next article:The transceiver program based on single chip microcomputer and 8279 driving digital tube display and communicating with the host computer

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号