Design of High-speed Serial Output Port of AT89C51 Single-chip Microcomputer

Publisher:心有归属Latest update time:2012-03-16 Source: 单片机与嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The serial port of the AT89C51 (compatible with MCS-51) microcontroller can expand multiple 8-bit parallel I/O ports using a shift register chip in mode 0. In the LED dot matrix display application system, the data synchronous shift output method is generally adopted, and the shift register chip (such as 74LS595) is used to expand the parallel I/O port to drive the LED dot matrix display. The LED dot matrix display adopts a scanning method. In order to avoid flickering, 50 screens of dot matrix display data need to be transmitted per second. Therefore, a large amount of data needs to be sent to the display drive circuit part through synchronous shifting, which requires the microcontroller to output data quickly. The serial port of the AT89C51 microcontroller is in mode 0. The data is output at a baud rate of fosc/12. After 1 byte of data is written to SBUF, it is necessary to check whether the interrupt flag TI is "1" and clear "0" TI or delay several machine cycles before continuing to write a data. The output speed is slow. In the LED dot matrix display application system, the communication between the system and the PC needs to use the serial port of the microcontroller, and the synchronous shift output port of the display data can only be expanded separately. The high-speed serial synchronous shift output port (hereinafter referred to as the extended serial port) circuit introduced in this article adopts modular design and provides implementation solutions based on TTL and PLD circuits. The baud rate is increased to fosc, and data output does not require waiting or delay.
1. Extend the connection between the serial port and the microcontroller
The block diagram of the extended serial port circuit is shown in Figure 1. Similar to the parallel memory chip, the extended serial port is regarded as an external RAM address unit, directly connected to the external data bus of AT89C51, D0~D7 are data lines, CE is the chip select signal, WE is the write pulse signal, and also the output control signal of the extended serial port. The oscillation signal of the AT89C51 external crystal oscillator is shaped by two NAND gates to provide the clock pulse XTAL2 for the extended serial port. DAT and CLK are the data output terminal and synchronous shift pulse output terminal of the extended serial port respectively.



2. Operation Instructions
Assume that the address assigned to the extended serial port by AT89C51 is 0000H, use MOVX@DPTR, A or MOVX@R0 , A instruction to write data to the extended serial port and shift the data. The following program segment sends 32 bytes of data with the first address of 30H in the internal RAM data area to the extended serial port for synchronous shift output:
MOV P2, #00H; Set the extended serial port address high 8 bits
MOV R1, #30H; Set the first address of the internal RAM data area
MOV R7, #32; Output byte count
LOOP: MOV A, @R1; read 1 byte from the internal RAM data area
INC R1; points to the next address unit in the internal RAM data area
MOVX @R0, A; data is sent to the extended serial port output
DJNZ R7, LOOP; 32 bytes not sent yet, continue
RET3

. Design scheme and working principle based on TTL circuit
Figure 2 is an extended serial port circuit implemented with TTL circuit. 74LS74 is a dual rising edge D flip-flop with preset and clear functions. D1~D5 constitute an 8-pulse generator (counter principle). 74LS165 is an 8-bit parallel input serial output shift register. When the CPU executes the MOVX@R0, A (or MOVX @DPTR, A) instruction, the data is latched in the 74LS165. The timing of generating 8 pulse signals is shown in Figure 3. In Figure 3, Q0~Q5 are the output ends of 6 D flip-flops respectively. The extended serial port chip select is valid (CE=0). When the write pulse WE arrives, WR=0. At the rising edge of the clock pulse XTAL2, the output Q0 of the flip-flop D0 is 0, and Q0 resets Q5, making Q5=1; after the write pulse ends, WR=1, then WR·Q5=1, the reset end of the counter is invalid, the counter starts counting, and outputs a square wave pulse at the Q1 end; after the 8th pulse ends, Q5=1, then WR·Q5=0, the counter is reset, stops counting, and waits for the next write pulse. The 8 pulses output from the Q1 terminal are connected to the CLK2 (pin 15) of the 74LS165 as synchronous shift pulses, and are also the synchronous shift pulse output signals of the extended serial output port: the data latched in the 74LS165 by the MOVX instruction is output from the data terminal (DAT) of the extended serial output port under the action of the synchronous shift pulse (CLK). [page]
4. Design scheme based on PLD circuit
Using programmable gate array devices to design circuits can simplify circuits and reduce the number of devices. The 8-pulse generator circuit in the dotted box in Figure 2 can be realized with one GAL16V8D, as shown in Figure 4. XTAL2 is the extended serial port clock pulse input signal, WR is the write pulse signal when the chip select is valid, and Q1 is the 8-pulse output terminal. Write the logical expression of Q1~Q5 according to the timing diagram shown in Figure 3. The following is an example of the logic design of the GAL16V8D chip.
AFT16V8D
NAME:ED13_U00
AUTHOR:FUHAO
DATE:04.15.1999
;1 2 3 4 5 6 7 8 9 10 (pin)
CLK WR NC NC NC NC NC NC NC GND
;11 12 13 14 15 16 17 18 19 20 (pin)
OE Q1 Q2 Q3 Q4 Q5 NC NC NC VCC
Q1: =/Q1*WR*/Q5
Q2: =/Q2*Q1*WR*/Q5
+Q2*/Q1*WR*/Q5
Q3: =/Q3*Q2*Q1*WR*/Q5
+Q3*/Q2*WR*/Q5
+Q3*/Q2*WR*/Q5
Q4: =/Q4*Q3*Q2*Q1*WR*/Q5
+Q4*/Q3*WR*/Q5
+Q4*/Q2*WR*/Q5
+Q4*/Q1*WR*/Q5
Q5: =/Q5*Q4*Q3*Q2*Q1*WR
+Q5*/Q4*WR
+Q5*/Q3*WR
+Q5*/Q2*WR
+Q5*/Q1*WR
DESCRIPTION

Conclusion
The method of expanding the high-speed serial synchronous shift output port of the single-chip introduced in this article, as well as the implementation scheme based on TTL and PLD circuits, have been successfully applied in the LED dot matrix display system. The expansion serial port adopts modular design and is easy to transplant to other application systems.
Reference address:Design of High-speed Serial Output Port of AT89C51 Single-chip Microcomputer

Previous article:Various methods of accurate timing programming of single chip microcomputer timing interrupt
Next article:Intelligent power cabinet based on single chip microcomputer C8051F060

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号