MCU learning knowledge points Raiders (finished articles)

Lead: This issue is the final return of this MCU learning knowledge point. We will list the first three times together to facilitate readers to review and learn. The main knowledge points are the serial port communication, interface and practical case practice of MCU - the learning of MCU music program design. SCM is really difficult for beginners to understand, many students who have studied SCM or electronic enthusiasts, even when they graduated, they still have nothing. Based on this, the electronic enthusiast network will integrate the "single-chip learning knowledge point Raiders", divided into four series, to readers, so stay tuned! This series also has collection and reference value for electronic engineers in the industry.

MCU learning knowledge points Raiders (finished articles)

See related series

MCU learning knowledge points Raiders (1)

   MCU learning knowledge points Raiders (2)

    MCU learning knowledge points Raiders (3)

Series four

Click to browse the next page 22: Design of serial port communication program of single chip microcomputer

Click to browse the next page 23: LED digital tube static display interface and editing

Click to browse the next page 24: Dynamic scan display interface circuit and program

Click to browse the next page 25: Microcontroller keyboard interface programming

Click to browse the next page 26: Single-chip matrix keyboard interface technology and

Click to browse the next page 27: Some basic concepts about microcontroller

Click to browse the next page 28: Actual case practice - MCU music program design

22, microcontroller serial port communication program design

1. Serial port mode 0 application programming 8051 microcontroller serial port mode 0 is the shift register mode, externally connected to a shift register that is connected in parallel, can expand a parallel port.

Click to browse the next page

"Single-chip serial port communication program design hardware connection diagram"

Example: Use the 8051 single-chip serial port to connect the CD4094 to expand the 8-bit parallel output port. As shown in the figure, each of the 8-bit parallel ports is connected to an LED, and the LED is required to be in a running light state. The serial port mode 0 data transmission can be interrupted or queried. In either case, the TI or RI flag should be used. When serial transmission, TI can be set (after sending a frame of data) to cause an interrupt request, send the next frame data in the interrupt service routine, or by querying the state of TI, as long as TI is 0, continue to query, TI is 1 End the query and send the next frame of data. At the time of serial reception, an interrupt is caused by the RI or an RI inquiry is made to determine when to receive the next frame of data. Regardless of the method used, the control register SCON must be initialized before starting communication. In mode 0, 00H will be sent to SCON.

-----------------Single-chip serial port communication program design column ------------------------- -

ORG 2000H

START: MOV SCON, #00H ; Set the serial port working mode 0

MOV A, #80H; the highest position light is on first

CLR P1.0 ; Turn off parallel output (the "dark red" phenomenon of each LED during the image transmission process)

OUT0: MOV SBUF, A ; start serial output

OUT1: JNB TI, OUT1; output is not finished

CLR TI; Finished, clear the TI logo for the next transmission

SETB P1.0; open parallel port output

ACALL DELAY; delay for a while

RR A ; loop right shift

CLR P1.0; turn off parallel output

JMP OUT0 ; loop

Note: The DELAY delay subroutine can use the delay subroutine used when we talk about the P1 port flow lamp. It is not given here.

Second, serial port asynchronous communication

Org 0000H

AJMP START

ORG 30H

START:

Mov SP, #5fh ;

Mov TMOD, #20h ;T1: working mode 2

Mov PCON, #80h ;SMOD=1

Mov TH1, #0FDH ; Initialize baud rate (see table)

Mov SCON, #50h ;Standard UART settings

MOV R0, #0AAH; the number to be sent

SETB REN; allowed to receive

SETB TR1; T1 starts working

WAIT:

MOV A, R0

CPL A

MOV R0, A

MOV SBUF, A

LCALL DELAY

JBC TI, WAIT1; if TI is equal to 1, clear TI and turn WAIT1

AJMP WAIT

WAIT1: JBC RI, READ; if RI is equal to 1, clear RI and turn READ

AJMP WAIT1

READ:

MOV A, SBUF; the number to be obtained is sent to the P1 port

MOV P1, A

LJMP WAIT

DELAY: ; delay subroutine

MOV R7, #0ffH

DJNZ R7, $

RET

END

Compile the program, write to the chip, insert the experiment board, and connect the experiment board to the serial port of the host computer with a read-through cable to experiment. The above program function is very simple, that is, to send the number 55H and AAH to the host at intervals, and send the number sent by the host to the P1 port. You can use the serial port wizard to do experiments on the PC side. The serial port wizard is available for download on my homepage. After running the serial port wizard, press the “Set Parameters” button on the main interface to enter the “Set Parameters” dialog box, and set the parameters as follows. Note that serial port 2 is used on my machine. If you are not serial port 2, please change the serial port settings yourself.

Click to browse the next page

After setting, press OK to return to the main interface. Note that there is a drop-down list on the right, and you should select “By hex”. Then press "Start to send", "Start receiving" will be fine. According to this setting, there should be two lights on the experiment board and 6 lights off. You can change the sending characters in the setting parameters such as 55, 00, FF, etc., observe the light on and off, and analyze the reason. You can also change the "by hex" in the drop-down list on the main interface. Observe the phenomenon in hexadecimal or "by ASCII characters" and analyze it carefully. This is also very good for everyone to understand hexadecimal, decimal, ASCII characters. The program itself is very simple and has comments, which are not explained here.

Third, the interrupt version of the above program

Org 0000H

AJMP START

Org 0023h

AJMP SERIAL ;

ORG 30H

START:

Mov SP, #5fh ;

Mov TMOD, #20h ;T1: working mode 2

Mov PCON, #80h ;SMOD=1

Mov TH1, #0FDH ; Initialize baud rate (see table)

Mov SCON, #50h ;Standard UART settings

MOV R0, #0AAH; the number to be sent

SETB REN; allowed to receive

SETB TR1; T1 starts working

SETB EA; open total interruption

SETB ES; open serial port interrupt

SJMP $

SERIAL:

MOV A, SBUF

MOV P1, A

CLR RI

RETI

END

This program is not written to the sender, you can add it yourself.



Digital currency transactions allow users to convert existing digital currencies into other digital currencies. The entire transaction does not involve any legal tender. Because of the relatively loose regulation, the mainstream digital currency trading platform also opened this function.Digital Asset Exchange (DAE) is a platform for matching transactions between digital currencies, digital currencies and legal currencies. It is the main place for encrypting the circulation and price determination of digital currency transactions.

Compared with traditional stock exchanges, digital asset trading platform not only matches transactions, but also plays the role of market maker and investment bank. The role of the market maker in the trading platform can increase the liquidity of the market, and the trading platform can earn the transaction price difference. The role of the investment bank of the trading platform is to provide services such as issuance and underwriting of digital currency, from which the trading platform collects money fees, or collects deposits in the form of community voting of the trading platform.

Currency Exchange

Currency Exchange,Digital Currency Exchange,Virtual Digital Currency Exchange,Display Currency Exchange

China youbi digital assets limited , https://www.ubcoinchina.com

Posted on