In the development of modern instruments, human-computer interaction functions are playing an irreplaceable role. Instruments with user-friendly human-computer interaction interfaces will be easier to operate and use, thereby improving work efficiency. Liquid crystal displays (LCDs) have the characteristics of low power consumption, low price, long life, and convenient interface control, and are playing an increasingly important role in the field of scientific research and design. FPGA, as an interface chip for microcontroller peripherals, can greatly simplify the interface circuit. By programming FPGA, commonly used functions such as decoding and address gating can be realized.
This paper takes the C8051F020 microcontroller and FPGA interconnection system as the control core, takes the LCD display controller T6963C as an example, and combines it with the line scanning keyboard to briefly describe the design of a human-computer interaction function.
1 System design:
FPGA can greatly expand the resources of the MCU, but the human-computer interaction function should still minimize the consumption of MCU and FPGA resources, so that more on-chip resources can be used for the expansion of other functions. Using FPGA to scan the keyboard can save the resources of the MCU and can also flexibly expand the keyboard. Considering that the LCD control is more complicated, the MCU is still used to control the LCD, so that the various functions of the LCD can be used to the greatest extent. The system block diagram is shown in Figure 1.
2 Hardware circuit and FPGA interface design:
2.1 Bus interface design:
Here we use a system that interconnects the single-chip C8051F020 and the CycloneⅡ FPGA. The C8051F020 device is a fully integrated mixed-signal system-level MCU chip with 64 digital I/O pins. It is fully compatible with the 8051 and has greatly improved speed. 70% of the instructions are executed in 1 or 2 system clock cycles, and only 4 instructions are executed in more than 4 system clock cycles. In addition, the C8051F020 series MCU has several key improvements to the CIP-51 core and peripherals, which improves overall performance and makes it easier to use in the final application. For example, it provides 22 interrupt sources, 7 reset sources, programmable cross switches, 8-bit A/D converters, 12-bit D/A converters, etc.
The Cyclone II series FPGAs expand the density of low-power FPGAs to 68,416 logic units, and provide up to 622 available I/O interfaces and up to 1.1 Mb of on-chip storage units [3]. The Cyclone II series successfully combines high efficiency with low power consumption and can be used in automation, communications, video playback and other fields. In order to take into account the cost issue, this system uses the cost-effective EP2C8 FPGA as the interface device.
In order to maximize the development of the resources of the single-chip microcomputer, the high ports of the single-chip microcomputer, namely P4~P7, are connected to the FPGA, and the external devices are accessed through the FPGA. The 3-8 decoder is implemented in the FPGA through Verilog HDL language programming, thereby realizing the expansion of the single-chip microcomputer address bus. The 3-8 decoder provides an enable signal for the key value reading of the LCD and keyboard, as shown in Figure 2.
[page]
2.2 T6963C and its interface design:
The T6963C LCD controller is mostly used in small-scale LCD devices and is often assembled on graphic LCD modules in the form of a graphic LCD module with a built-in controller.
The microcontroller has two ways to access T6963C: direct access and indirect access. Direct access uses three buses to control I/O device access; indirect access is controlled by the microcontroller providing a parallel interface and controlled by program-controlled timing. To simplify the program, direct access is used here.
The FS1 pin of this LCM is used to control the font of the displayed characters. When FS1 is high, the LCD displays 6×8 characters; when FS1 is low, the LCD displays 8×8 characters. Through practice, 6×8 characters are more beautiful when displaying English and numbers; 8×8 characters are more convenient when displaying Chinese characters. The general system uses the method of grounding or connecting FS1 to a high position to fix the font, while this system uses P2.1 to control FS, and the function of changing the font is realized by changing the address, making the interface display more flexible.
2.3 Keyboard circuit design:
The keyboard is a commonly used single-chip microcomputer input device, which is divided into coded keyboard and non-coded keyboard. The recognition of the closed key on the keyboard is realized by a dedicated hardware decoder, and the key number or key value is generated, which is called a coded keyboard; the keyboard that is recognized by software is called a non-coded keyboard. The most commonly used non-coded keyboard in the measurement and control system composed of single-chip microcomputers and intelligent instruments is the non-coded keyboard. This system design is programmed in FPGA to realize the row scanning of 3×6 keyboards.
Due to the mechanical characteristics of the key, there will be a series of jitters at the moment of closing and opening. The jitter of the key will cause a key to be misread multiple times, so de-jittering must be performed. The commonly used method is delay de-jittering. After the FPGA generates the key value, it sends an interrupt to the microcontroller and waits for the microcontroller to read the key value. Since the human brain has a relatively long reaction time, the keyboard interrupt can be at a relatively low priority, so this article connects the keyboard interrupt to the external interrupt 7.
3. Software Design:
The software design follows the principles of structured and hierarchical design. The bottom-level functions communicate directly with the hardware, while the upper-level functions directly call the bottom-level functions to implement the corresponding functions, thus completely separating the upper-level functions from the hardware environment. When the hardware environment changes, the program can be transplanted by simply modifying the bottom-level functions.
3.1 Programming design of LCD driver module:
The bottom layer functions of this module need to implement functions such as writing control words, writing parameters, and checking busy. Due to the direct access, the functions of writing control words and writing parameters only need to send numbers to the address of the control port or data port. Since LCD is a slow device, a busy check is required before each writing of control words and parameters. The status word of T6963C has a total of 7 valid status bits, as shown in Table 1. Among them, STA1~STA3 are the most commonly used, and under normal circumstances, there is no need to check the busy program for STA5~STA7.
3.1.1 Initialization of LCD driver module:
The biggest feature of T6963C is its unique hardware initial value setting function, which displays the parameters required by the driver, such as the duty cycle coefficient. The number of bytes/lines transmitted by the driver and the font selection of characters are all set by the pin level, so that the initialization of T6963C is basically set when it is powered on, and the focus of software operation can be fully used on the design of the display screen. Therefore, during initialization, you only need to set the first address and width of the text area and graphic area according to the actual situation, as well as the CGRAM offset address, synthesis method, cursor shape, etc., and it can be used normally.
The initialization function of the LCD driver module is as follows:
void LcdInitial(void)
{
LcdWriteDataD(0x00,0x00,0x40); //Set the first address of the text area to 0000H
LcdWriteDataD (0x20, 0x00, 0x41); //Set the text area width to 20H bytes
LcdWriteDataD(0x00,0x04,0x42); //Set the first address of the graphics area to 0400H
LcdWriteDataD(0x20,0x00,0x43); //Set the width of the graphics area to 20H bytes
LcdWriteDataD(0x03,0x00,0x22); //Set CGRAM offset address, the first address of display memory is 1800H
LcdWriteDataN (0xa7); //Set the cursor shape to 8×7
LcdWriteDataN (0x80); // Enable the internal character generator, logical "or" synthesis
LcdWriteDataN (0x9c); // Enable text and graphic display, disable cursor
LcdClear(3); //Clearing
}
3.1.2 Text display in English and Chinese characters:
Since the fonts of commonly used characters such as English and numbers have been solidified in CGROM, when displaying English, you only need to specify the display address and then enter the label corresponding to the character. The display of Chinese characters is similar to that of English. However, due to its complexity, a Chinese character requires 4 sets of dot matrices to be fully displayed. After initialization, the 4 parts of the Chinese character font are sequentially input into CGRAM. When using it, you only need to calculate the display address of each part to display the Chinese character perfectly.
For the input of a string of English characters, the characteristics of the string can be used for operation. By detecting the '' character to determine the end of the English string, the work of manually calculating the length of the sentence when calling this display function is avoided. The ASCII code value of the English character and its corresponding label in the CGROM are exactly 0x20 different, so only a simple subtraction is required to achieve the conversion of the label. In addition, when performing continuous display of English, the automatic data write instruction of T6963C is used to improve the display efficiency.
To display a string of Chinese characters, you only need to call a single Chinese character display program in a loop. Note that because the string in C51 language cannot support Chinese characters, the length of the Chinese character string must be calculated manually and passed to this display function as a function. [page]
A total of 32 Chinese characters can be stored in the character generator CGRAM. For applications that need to display more Chinese characters, the 16 most commonly used Chinese characters can be selected from the characters to be displayed and stored in the CGRAM. The remaining Chinese characters are only dynamically written to the CGRAM when they are needed. In this way, the display efficiency is improved and the problem of too small CGRAM is solved.
3.1.3 Graphical display:
In addition to using text to display Chinese characters, you can also use graphic display. The specific method is to save the font in the code segment of the microcontroller in the form of an array, and send the data to the graphic area when it needs to be displayed. In addition, using graphic display, you can also write a point drawing program to display the corresponding waveform or write a drawing program to draw a simple table, so that the system display results are more intuitive and easy to analyze.
3.1.4 Text effects:
T6963C can set the text attribute area and implement special effects such as reverse white, forward flashing, and reverse flashing for the text. When using it, just set the graphic display to the text attribute area. At this time, the content of the graphic area will not be displayed. If the graphic area and the text attribute area are divided into different areas of CGRAM, the content of the graphic area can be saved. With text special effects, the optional options and the current options can be indicated through effects such as reverse white or flashing, making the interface easier to operate.
3.2 Human-computer interaction interface design:
In addition to the basic 10 numeric keys, there are also up, down, left, right, confirm, cancel and other keys. In addition, the design of the key positions is more in line with people's key habits. A hierarchical menu is used in the interface. After selecting a function in the first-level menu, you will enter the next-level menu to set the function in more detail. In the human-computer interaction interface, you can use the direction keys to select functions, and the numeric keys are only used for data input.
The interface makes full use of text effects. The reverse display of options indicates that the option has been selected; the reverse flashing of options indicates that users can change options through the arrow keys. In the interface that requires numeric input, the cursor is turned on to indicate the place for numeric input to the user. In addition, the design of necessary warning and error interfaces will provide users with more information, making the human-computer interaction interface more user-friendly.
4 Conclusion:
This system uses keyboard + LCD input and output devices, and can realize the design of interface circuits of various other peripherals through FPGA, which reduces the occupation of single-chip microcomputer resources and makes the design flexible and convenient. At the same time, FPGA can also provide resources such as memory and I/O ports for single-chip microcomputer. The circuit designed in this paper has strong scalability, and on this basis it can be expanded into various systems with friendly interfaces, such as controllable gain amplifier, audio signal analyzer, integrated operational amplifier analyzer, etc. In practice, the system is stable, easy to use and practical.
Previous article:Design of Ultrasonic Distance Measurement System Based on 51 Single Chip Microcomputer
Next article:Interface Design between 51 MCU and TLV2548 Serial A/D
Recommended ReadingLatest update time:2024-11-16 15:43
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- MATLAB and FPGA implementation of wireless communication
- Intelligent computing systems (Chen Yunji, Li Ling, Li Wei, Guo Qi, Du Zidong)
- Summary of non-synthesizable statements in FPGA
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Suspicious signal from outer space
- Download gift: USB Type C related development and test materials, read it when you have nothing to do, and you will become a master by accident
- Qorvo explains WIFI and 5G clearly
- SPIN3201 (STSPIN32F0) three-resistance control board: FOC motor drive schematic/code/debugging documents and other detailed information...
- Should segment display screens be backlit? How to add it?
- Installation and setup of CCS StarterWare, successfully compiling a project with CCS7.3
- EEWORLD University ---- Operational Amplifier Video Tutorial
- Have you ever encountered the problem of USB drive repair? Is there any good tool you can recommend?
- Several major wireless technologies
- How to modify the video recorder startup screen