LED display hardware design based on single chip microcomputer

Publisher:黄金大花猫Latest update time:2012-03-08 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Since the 1990s, with the continuous improvement of the design and manufacturing level of LED display technology, LED digital screens have gradually been widely used in production and life. With its unique display medium, LED digital screens have shown advantages in the fields of large-area, all-weather, high-brightness and ultra-high-brightness display screens. In the more than ten years of development of LED display technology, new devices and new technologies have been continuously adopted, manufacturing costs have gradually decreased, and production division of labor has been continuously refined. However, while being widely used, several defects of LED display technology have also been exposed. In general, the technology is not yet mature, and the standards have not yet been fully established. There are many aspects that deserve further research and improvement.

With the rapid development of large-scale integrated circuits, the computing and control capabilities of microprocessors have greatly increased. Single-chip computers have assumed intelligent tasks in many industrial and civilian systems. Compared with the rapidly developing computing speed, their port expansion capabilities are much inferior (limited number and difficult to expand). Therefore, a lot of energy has to be invested in saving ports during the research and development process. At present, in order to solve the port expansion problem in China, software processing can be used, which increases the difficulty of software writing, or a dedicated chip for port expansion can be used. These two methods will increase the software cost or the complexity of the hardware circuit, which is not conducive to the development of some small systems. The STC12C5A60S2 microcontroller has a variety of serial transmission modes, which solves this contradiction to a certain extent.

LED digital screens are widely used. They can not only display text, but also various graphics, charts, and even various animation effects. They are a powerful tool for advertising and news dissemination.

This paper uses STC12C5A60S2 microcontroller, interface NAND flash memory and host PC to realize the control of 16×128 dot matrix LED digital screen.

1. Chip selection

1.1 Screen

Since the screen is a commercial product, the system chip is preferably selected to match the screen. The screen has its own power supply, which can directly convert the energy of the battery into a 5 V DC power supply, and this power supply is also output to the system board through the interface cable of the screen. Therefore, the system can directly use this power supply without having to prepare its own power supply circuit.

1.2 Microcontroller

Taking into account the screen and system requirements, the single-clock/machine cycle (1T) microcontroller STC12C5A60S2 produced by China Hongjing Technology was selected.

STC12C5A60S2 is a new generation of high-speed 8051 microcontroller. Its instruction code is fully compatible with the traditional 8051, but it is 8 to 12 times faster. It integrates the MAX810 dedicated reset circuit internally, and its operating voltage range is 3.5 V to 5.5 V, which meets the required voltage. Since it is a single-cycle 8051 (the traditional 8051 is 12 cycles), you can choose an 11.059 2 MHz crystal oscillator that is easier to obtain an accurate baud rate without worrying about the reduction of operating speed.

STC12C5A60S2 has 60 KB user application space, 256 B RAM and 1024 B XRAM. It can meet the needs of program code and buffer definition. There is also a flash memory area independent of the program storage space, which can be used as EEPROM in application programming.

STC12C5A60S2 has dual UART and ISP serial ports, and the serial port resources are sufficient for system use. In addition, through the software provided by Macrocrystalline Technology, program download can be easily achieved using UART. STC12C5A60S2 has 36 general I/O ports, most of which can be bit-controlled and have strong push-pull output capabilities, which are sufficient for system use.

STC12C5A60S2 has four 16-bit timers and an independent baud rate generator, and two PCA modules, which can obtain rich timer resources. STC12C5A60S2 has a PDIP-40 package chip, which is easy to quickly enter the experiment.

1.3 Flash memory

Because the capacity of the Chinese character library of 16 × 16 dot matrix is ​​about 250 KB, and the addressing space of MCS51 is only 64 KB. For ordinary memory chips with an interface capacity greater than 64 KB, bus expansion must be performed, and the method of latching the address twice is used for reading and writing, which requires complex circuits and takes up a long access time. Similarly, the pin structure of NOR flash memory is similar to that of EPROM, with the same interface complexity and very high cost. To realize a simple interface between the microcontroller and the character library chip (without expansion), only a serial structure memory or a command, address and data multiplexing bus structure memory can be selected.

Most serial memory is EEPROM, which does not have a large capacity and is not suitable for font library chips. Therefore, only NAND flash memory with command, address and data multiplexing bus is used as font library storage chip.

The capacity required for the font library is not large, but it is best to be powered by 5 V, and the programming cache requires a smaller chip. The K9F4008W produced by SAMSUNG is a 512 KB NAND flash memory with only 8 IO ports and a wide operating voltage range (3 V~5.5 V). It is compatible with 3 V and 5 V hardware systems, and only requires a 32 B buffer during frame programming, which is just suitable as a chip for font library storage.

Therefore, the electrically erasable feature of the flash memory chip is very suitable for occasions where the character library needs to be replaced. Therefore, this chip is an ideal Chinese character library memory.

2 Circuit Design

The schematic diagram of the circuit designed according to the overall structure of the system is shown in Figure 1.

[page]

3 Overall design

3.1 Screen interface module

The screen interface includes the screen interface header file, screen buffer definition, screen interface initialization, refresh timer interrupt service program and SPI interrupt service program.

The header file screen.h of the screen interface should make the screen buffer visible to other applications and provide a screen initialization function. The specific definition is as follows:

#ifndef _SCREEN_H_

#define _SCREEN_H_

#include "incboard.h"

extern u8 xdata SCR_BUF[16][16];

void screen_init(void);

#endif

This exposes the structure of the screen buffer to the application, but the application does not have to worry about the specific screen refresh operations.

The implementation of the specific screen interface is concentrated in a file screen.c. The details are as follows:

First the screen buffer definition:

u8 xdata SCR_BUF[16][16]_at_0x0000;//~0x00ff 256Bytes The following is the definition of the current display row and output column variables, which are static variables and are not visible to the application.

static u8 data row,col;

Then comes the screen initialization, including the initialization of refresh timer 0, the initialization of SPI, the initialization of the latch bLatch signal, the initial clearing of the screen buffer, and the initialization code of the priority and enable bits of the timer and SPI interrupts.

The interrupt service routines of SPI and timer 0 are the key to the screen interface.

The interrupt service routine of timer 0 first performs scan line increment modulo operation and outputs the scan line. Then, it takes out the first byte of the corresponding line in the screen buffer according to the scan line and sends it to the SPI port. At the same time, the column increments.

void display_ONe_screen(void)interrupt 1 using 3{

row = (++row)&0x0f;

P0 = (P0 & 0xf0) | ((~row) & 0xf);

col = 0;SPDAT = ~SCR_BUF[row][col++];

}

For a screen driver written in this way, the application only needs to write the data to be displayed into the screen buffer after initializing the screen, without having to worry about the details of the screen display.

3.2 UART Interface

The UART interface is responsible for sending and receiving data with the host computer. Although sending can be done synchronously, receiving must be done asynchronously. Therefore, the core of the UART interface should still be an interrupt service program.

The header file uart.h of the UART interface hides the information of the receiving buffer. The functions that users can call are only initialization, sending and receiving.

#ifndef _UART_H_

#define _UART_H_

void uart_init(void);

void uart_put_c(u8 ch);

u8 uart_get_c(u8 *);

#endif

The UART interface implementation first defines a receive buffer FIFO, as well as the read subscript uart_rd and write subscript uart_wr for the FIFO. They are static variables visible in the file:

static u8 xdata uart_buf[64];

static u8 uart_rd,uart_wr;

bit fSend

UART initialization includes FIFO initialization and UART format, baud rate, and interrupt initialization. The code is omitted.

The ISR of UART is mainly used for receiving, unconditionally loading data into FIFO, and adjusting the write pointer.

static void uart_isr(void)interrupt 4 using 1{

if (RI) {RI = 0;

uart_buf[uart_wr++] = SBUF;

uart_wr &= 0x0f;

}

}

The sending program provided to the user first detects the sending end mark. If it is 0, it means that the last sending has not been completed, and the error message 1 is directly returned.

[page]

Otherwise, the information to be sent is sent and the send end flag is cleared. The purpose of designing the sending program in this way is to not limit the sending wait to the bottom layer of the interface, but to give the upper layer an opportunity to decide whether to wait for the end of sending.

u8 uart_put_c(u8 ch){

if (! TI) return 1;

TI = 0;SBUF = ch; return 0;

}

Similarly, the receiving program also gives the upper layer a chance to choose to wait. The receiving function first determines whether the receiving FIFO is empty. If it is empty or the input pointer parameter is wrong, it directly returns an error. Otherwise, it reads data from the FIFO and stores the data to the address pointed to by the pointer, and then returns success.

u8 uart_get_c(u8 *ch){

u8 i;

if (!ch) return 1;

if ((i = (uart_rd+1)&0x0f) == uart_wr) return 1;

uart_rd = i; *ch = uart_buf[i]; return 0;

}

3.3 Flash memory interface

Flash memory access has a special timing, and the internal structure of flash memory is also very different from the specific application requirements. Therefore, the flash memory interface needs to be carefully designed.

The storage structure organization of the K9F4008 flash memory chip is shown in Figure 2.

The storage of K9F4008 flash memory is in blocks, and each chip has 128 blocks. Each block has 32 rows, each row has 4 frames, and each frame contains 32 bytes. The total chip size is 512 KB.

The flash memory initialization function provided by the flash memory interface includes processing for such situations. The initialization function needs to read a block mapping table from the first block of the flash memory. The table subscript is the logical sector, and each item in the table stores the physical block number corresponding to the logical sector. The initialization function performs read and write verification on the flash memory when necessary, and then deletes the bad block from the table. Then it looks for a new good block and fills its number into the table entry corresponding to the logical sector. In this way, the application can only see the continuous sector numbers, but does not know which block the sector corresponds to.

The flash memory interface header file Flash.h is as follows:

#ifndef _K9F4008_H_

#define _K9F4008_H_

void read_log_page(u8 sector,u8 page,u8 xdata *buf);

u8 prog_log_page(u8 sector,u8 page,u8 xdata *buf);

void erase_log_blk(u8 sector);

bit flash_init(void);

#endif

To implement the flash memory interface, the first step is to define the basic operations of the flash memory according to the timing of the manual. Here, the basic operations are implemented by macro definition.

#define W_CMD(cmd_)

bCLE=1; bWE=0; P2=(cmd_); bWE=1; bCLE=0

#define W_ADDR(addr1_,addr2_,addr3_)

bALE=1; bWE=0; P2=(addr1_); bWE=1;

bWE=0; P2=(addr2_); bWE=1;

bWE=0; P2=(addr3_); bWE=1;

bALE=0

#define W_DAT(dat_) bWE=0; P2=(dat_); bWE=1

#define wait_RB while (! bRB)

#define l2p(x_) fat_tbl[(x_)]

3.4 EEPROM

The internal integrated EEPROM is separated from the program space. The internal DATAFLASH can be used as EEPROM by using ISP/IAP technology, and the erase and write times are more than 100,000 times. EEPROM can be divided into several sectors, each sector contains 512 B. When using, it is recommended to put the data modified at the same time in the same sector, and the data not modified at the same time in different sectors, and it does not have to be full. The erase operation of the data memory is performed by sector.

sfr IAP_DATA = 0xC2; //Flash data register

sfr IAP_ADDRH = 0xC3; //Flash address HIGH

sfr IAP_ADDRL = 0xC4; //Flash address LOW

sfr IAP_CMD = 0xC5; //Flash command register

sfr IAP_TRIG = 0xC6; //Flash command trigger

sfr IAP_CONTR = 0xC7; //Flash control register

Define the EEPROM registers according to the instructions.

Keywords:MCU Reference address:LED display hardware design based on single chip microcomputer

Previous article:Single-phase electric meter measurement design based on electric energy chip and AT-Mega16 microcontroller
Next article:Design of automobile maintenance reminder system based on SPCE061A single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 16:20

51 MCU simply drives LCD1602
【LCD1602】 What is LCD1602 LCD1602 is an industrial character type liquid crystal that can display 16x02, or 32 characters, at the same time. The principle of LCD1602 liquid crystal display is to use the physical properties of liquid crystal to control its display area through voltage, that is, to display graphics. 1
[Microcontroller]
51 MCU simply drives LCD1602
ESP8266+51 MCU WIFI control multi-channel remote control switch program design
This is a design of a WIFI multi-channel remote control switch based on a single-chip microcomputer. It contains documents, programs, pictures and other materials. The actual picture is as follows:   The circuit schematic is as follows: Wifi switch component list 1) 9*15 multi-purpose board 2) STC89C52 microcontr
[Microcontroller]
ESP8266+51 MCU WIFI control multi-channel remote control switch program design
Conventional battery fast charging system based on ST72 single chip microcomputer
Introduction: Traditional conventional battery charging methods all use small current constant voltage or constant current charging, and the charging time is as long as 10 to 20 hours. In order to shorten the charging time, the charging current of the charging process must be controlled. Many manufacturers mist
[Microcontroller]
Conventional battery fast charging system based on ST72 single chip microcomputer
Design skills of PIC microcontroller pin interrupt program
Introduction: This paper mainly introduces the design skills of PIC microcontroller pin interrupt program. The pin change program designed in this way has low CPU overhead, high efficiency, and will not have the problem of shallow stack overflow, which improves the real-time performance of the system. 1. Brief Intro
[Microcontroller]
51 MCU Assembly Program Library
Introduction: The following are some subroutine code libraries commonly used in 51 microcontroller assembly language programming 1. On-chip RAM initialization subroutine 2. Off-chip RAM initialization subroutine 3. Off-chip RAM initialization subroutine (double-byte unit) 4. Internal RAM data copy procedure 5. Exter
[Microcontroller]
[STC MCU Learning] Lesson 10: Timers and Counters of MCU
Key points of this lesson: Register Part I. Table of Contents 1.10.1. Timer Introduction 1.10.2. Key to software control hardware - registers 1.10.3.51 Introduction to MCU Timer 1.10.4. Introduction to the main registers of the timer 1.10.5. Timer Programming Practice 1 1.10.6. Correction of timing time se
[Microcontroller]
[STC MCU Learning] Lesson 10: Timers and Counters of MCU
Design of a multifunctional electronic calendar based on AT89S52 single chip microcomputer
    As the pace of life accelerates, people's concept of time becomes more and more important, and the demand for electronic clocks and calendars increases. Therefore, the study of practical electronic clocks and their extended applications has a very practical significance and great practical value.     This system p
[Microcontroller]
Design of a multifunctional electronic calendar based on AT89S52 single chip microcomputer
MCU I/O port usage
1. Experimental purpose 1. Master the simple use of P3 port and P1 port. 2. Learn to write and use delay programs. 2. Experimental content 1. Experimental principle diagram: 2. Experimental content (1) P3.3 port is used as input port, and an external pulse is connect
[Microcontroller]
MCU I/O port usage
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号