SPI interface design of serial display driver PS7219 and microcontroller

Publisher:daasddlaLatest update time:2006-06-06 Source: 自动化与仪器仪表Keywords:register Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  0 Introduction

  In the microcontroller application system, in order to facilitate people to observe and monitor the operation of the microcontroller, it is often necessary to use a monitor to display the intermediate results and status of the operation, etc. Therefore, the display is often one of the indispensable external devices of the microcontroller system. There are many types of commonly used displays, among which LED (light-emitting diode display) is the most widely used one. It is especially suitable for situations with strong light and extremely weak light.

  To enable LED display, segment selection code and bit selection code must be provided. The traditional hardware decoding display interface widely uses the central processing unit CPU (such as Intel 8031) to expand the I/O port (such as 8255), and then uses a logic gate driver chip (such as 7407, etc.) to drive the corresponding bit codes and segments. code. In this design, the connections between chips are very complicated, and the reliability of the system operation is not high. It is increasingly unsuitable for the development requirements of integration and miniaturization of single-chip microcomputer systems. Especially for system parallel expansion I/O, its shortcomings are very obvious:

  (1) There are too many connections, the system wiring is complicated, and the printed circuit board wiring is inconvenient;

  (2) There are too many devices attached to the parallel bus, and the system operation is unstable. Low performance and reliability;

  (3) Large size and low integration level.

  It is precisely because of the above reasons that in recent years, various manufacturers have successively developed LED display drivers with higher integration, stronger driving capabilities, more driving digits, and complete functions.

  This article introduces a low-cost, high-performance multi-bit LED display driver PS7219 chip, as well as its specific SPI interface design and application software with the microcontroller 89C51.

  1 Introduction to PS7219

  PS7219 is a new type of 8-bit digital static display chip with serial interface. It is a 24-pin dual-in-line chip newly launched by Wuhan Liyuan Company. It adopts the popular synchronous serial peripheral interface (SPI) and can be easily interfaced with any kind of microcontroller and can drive 8-bit LEDs (or 64 independent LEDs), its pin diagram is shown in Figure 1.

             
  PS7219 has a 15×8 RAM function control register inside, which can facilitate address selection. Each digit can be controlled and refreshed independently without rewriting the entire display. The display digital brightness can be controlled by numbers, and each bit has a flash enable control bit. When pin CON (pin 13) is set to high level, all displays can be disabled to reduce power consumption, but at the same time it does not affect the modification of the control register. The PS7219 also has a power-down mode, a scan limit register that allows the user to select from a 1-digit display to an 8-digit display, and a test mode that forces all LEDs on. In addition, the PS7219A type has a built-in reliable uP monitoring circuit, which can provide an external high-level reset signal with a pulse width of 140ms and a typical trigger threshold of 4.63V.

  If N PS7219s are cascaded, N×8-bit LED display can be achieved.

  2 PS7219 pin functions

  The pin functions of PS7219 are shown in Table 1.

  3 PS7219 working process

  Figure 2 is the working sequence diagram of PS7219. It is feasible from Figure 2. DIN is the serial data input terminal. On the rising edge of CLK, one bit of data is loaded into the internal 16-bit shift register. The maximum input frequency of the CLK terminal can reach 500kHz. On each rising edge of the input clock signal On the rising edge of LOAD, 1-bit data is moved from DIN into the internal register. LOAD is used to load data. On the rising edge of LOAD, 16-bit serial input data is latched into the digital or control register. LOAD must go high at the same time as or after the rising edge of the 16th clock, but before the rising edge of the next clock, otherwise the data will be lost.

  A set of data is specified as a 16-bit binary data packet with the following format:

       ?


  Among them, D15~D12 bits are not used, and D11~D8 are the addresses of the internal 5 control registers and 8 LED display data registers. The address codes are as shown in Table 2. D7~D0 are the 5 control register command words or the data to be displayed by the 8 LED digital tubes. Because the control registers and display data registers are independently addressed, each register can be operated independently through the program. Under normal circumstances, the program sends control commands first, and then sends data to the display register. However, it must be noted that each 16-bit group is sent starting from the highest bit of the high-order address section until the last bit of the low-order data word.

      

  PS7219 automatically scans and displays the numbers to be displayed in the directions specified by the five control registers, so it is necessary to understand the functions of each control register, which are described below:

  (1) Decoding mode register: set the BCD code for each number B (0 ~ 9, E, H, L, P and -) or non-code operation. Each bit in the register corresponds to a number. A logic high selects code BCD decoding, while a low selects the bypass decoder.

  (2) Display brightness register: D7~D4 bits can be arbitrary, while D3~D0 can be selected from 0000~1111. The larger the value of D3~D0, the brighter the LED display.

  (3) Scanning range register: The scanning range register sets the amount of displayed data, which can be from 1 to 8. They are generally displayed with a scan rate of 1.5kHz, 8-bit data, and multiplexing.

  (4) Power-down control register: D7~D1 bits can be any, D0=0, turn off all displays; D0=1, allow display.

  (5) Display test register: D7~D1 bits are optional; D0=00, LED is in normal working state; D0=1, display is allowed. The LED is in display test status.

  After sending the control word, the display subroutine can be called according to actual needs to change the contents of 1 to 8 data registers to complete the display function.

  4 SPI interface

  SPI is a synchronous serial peripheral interface, mainly used to communicate and exchange information with various peripheral devices in a serial manner. These peripheral devices can be simple TTL shift registers, or complex LCD display drivers or A/D conversion subsystems. The SPI interface is easily connected directly to various peripheral devices from many manufacturers.

  It uses 4 lines: serial clock line (SCK), master input/slave output line (MISO), master output/slave input line (MOSI), active low enable signal line (CS—— ). As shown in Figure 3. In this way, only 3-4 data lines and control lines can be used to expand various I/O devices with SPI interfaces. Its typical structure is shown in Figure 3.

?

  5 Interface Design

  5.1 Hardware Design


  The SPI interface of PS7219 is a high-speed synchronous serial I/O port, which allows 1 to 8-bit serial bit streams to move in and out of the chip at a specific transmission rate. But this requires the microprocessor to have SPI interface capabilities. For microprocessors without SPI or with the same interface capabilities, software must be used to synthesize SPI operations to interface with the PS7219. Here, the author uses the AT89C51, which is currently widely used, as an example to design the circuit. The interface circuit diagram is shown in Figure 4.

  Here, P1.6 of 89C51 is used for serial data output and is connected to the DIN pin of PS7219. P1.7 and P1.5 simulate the clock pulse CLK and data loading LOAD signal of PS7219 respectively through the program. The SA ~ SG and SDP terminals of PS7219 are connected to the a ~ f and dp terminals corresponding to each LED digital tube. DIG0 ~ DIG3 are respectively connected to the common cathode of the 4-bit LED digital tube to achieve bit selection. In addition, X25045 of XICOR Company is selected as the watchdog monitoring circuit.

  In fact, the number of digital tubes can be arbitrarily selected between 1 and 8 bits, which can be determined by the command word written to the scan boundary register. Note that in order to minimize the ripple caused by the peak digital driver current, an external 10μF electrolytic capacitor and a 0.1μF ceramic capacitor need to be connected between V+ and GND as close to the chip as possible. The PS7219 should be placed close to the LED display and the connections should be as short as possible. Both GND pins must be connected to the ground wire.

  PS7219 only needs a set of +5V power supply and three output ports of 89C51, and has no additional circuits. It can drive 1 to 8 LED displays, with adjustable display brightness and reliable operation.

 

  5.2 Software Programming:

  Open some storage units in the program memory area of ​​89C51, specifically used to define control command words. The specific values ​​of these command words are defined according to the working mode, display content, display digits, etc. you want to choose.

  Since the control register and display register of PS7219 are independently addressed, the display program is actually the corresponding control of 89C51 to PS7219 through P1.6 (DIN) with the cooperation of P1.7 (CLK) and P1.5 (LOAD) timing. Registers and data show the process of writing a 16-bit binary data packet to the register. So the key to the problem is to write a general write subroutine to move the contents of VWO into the shift register from high to low under the action of P1.7 (CLK), and finally by the rising edge of P1.5 (LOAD signal) Latch into the corresponding internal control register and data display register. The program flow chart of writing subroutine is shown in Figure 5.

  Whether initializing the control register of PS7219 or displaying numbers on the corresponding digital tube, it can be completed by calling the above general write subroutine.

           


  References

1 Pan Tianhong. Research on intelligent controllers for distributed control systems. Master's thesis of Jiangsu University of Science and Technology, 2000.1

2 Wuhan Liyuan. PS7219 is an 8-bit LED control driver with high-speed serial interface. Wuhan: Wuhan Liyuan Electronics Co., Ltd., 1999.2

3 Pan Tianhong. Optimized design of SPI serial bus and microcontroller system. Measurement and Control Technology, 2001.2

4 Li Hua. MCS51 series microcontroller practical interface technology. Beijing: Beihang University Press, 1999.12

Keywords:register Reference address:SPI interface design of serial display driver PS7219 and microcontroller

Previous article:The principle and application of 8-bit liquid crystal decoding driver MAX7232BF
Next article:Selection strategy and application introduction of backlight drive circuit

Latest Power Management 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号