This article takes the C8051F020 microcontroller and FPGA interconnection system as the control core, takes the liquid crystal display controller T6963C as an example, and combines the line scanning keyboard to briefly describe the design of a human-computer interaction function.
1 System Design Scheme
FPGA can greatly expand the resources of the microcontroller, but the human-computer interaction function should still minimize the resource consumption of the microcontroller and FPGA, so that more on-chip resources can be used for the expansion of other functions. Using FPGA scanning keyboard can save the resources of the microcontroller and also flexibly realize the expansion of the keyboard. Considering that LCD control is relatively complex, a single-chip microcomputer is still used to control
the LCD so that the various functions of the LCD can be utilized to the maximum 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 take 1 or 2 system clock cycles to execute, and only 4 instructions take more than 4 system clock cycles to execute. In addition, the C8051F020 series MCU has several key improvements to the CIP-51 core and peripherals, which improves the 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Ⅱ series FPGA expands the density scale of low-power FPGAs to 68,416 logic units, and provides up to 622 available I/O interfaces and up to 1.1 Mb of on-chip storage units. The CycloneⅡ series successfully combines high efficiency and low power consumption, and can be used in automation, communication, 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. [page]
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 Vel-ilog HDL language programming, thereby expanding the address bus of the single-chip microcomputer. The 3-8 decoder provides an enable signal for the key value reading of the LCD and keyboard, as shown in Figure 2.
2.2 T6963C and its interface design
The T6963C liquid crystal display controller is mostly used for small-scale liquid crystal display devices. It is often assembled on graphic liquid crystal display modules and appears in the form of built-in controller type graphic liquid crystal display modules.
The microcontroller has two ways to access T6963C: direct access and indirect access. Direct access uses three buses to control in the form of I/O device access; indirect access is controlled by the microcontroller providing a parallel interface and controlled in the form of program control timing. To simplify the program, direct access is used here.
The FS1 pin of the LCM is used to control the font of the displayed characters. When FS1 is high, the LCD displays 6x8 characters; when FS1 is low, the LCD displays 8x8 characters. According to practice, when displaying English and numbers, 6x8 characters are more beautiful; when displaying Chinese characters, 8x8 characters are more convenient. The general system uses the method of grounding or connecting FS1 to a high level 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 and intelligent instruments composed of single-chip microcomputers is the non-coded keyboard. This system design is programmed in FPGA to implement the row scan of the 3x6 keyboard.
Due to the mechanical characteristics of the key, there will be a series of jitters at the moment of closing and opening. The key jitter will cause a key to be misread multiple times, so de-jitter processing must be performed. The commonly used method is delayed de-jitter. After the FPGA generates the key value, it sends an interrupt to the single-chip microcomputer and waits for the single-chip microcomputer to read the key value. Because 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
Software design follows the structured and hierarchical design principles. The bottom-level function communicates directly with the hardware, and the upper-level function directly calls the bottom-level function to implement the corresponding function, so that the upper-level function is completely separated from the hardware environment. When the hardware environment changes, only the underlying functions need to be modified to achieve program migration.
3.1 Programming design of LCD driver module
The underlying functions of this module need to implement functions such as writing control words, writing parameters, and checking busy. Due to the use of 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.
[page]
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 the 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 in the design of the display screen. Therefore, during initialization, you only need to set the first address and width of the text area and the graphic area according to the actual situation, as well as the CGRAM bias address, synthesis method, cursor shape, etc., and it can be used normally.
The initialization function of the LCD driver module is as follows:
3.1.2 Text display of 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 matrix to be fully displayed. After initialization, the four 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, you can use the characteristics of the string to operate. By detecting the '\0' character to determine the end of the English string, you can avoid the work of manually calculating the length of the sentence when calling this display function. The ASCII code value of the English character and its corresponding label in CGROM are exactly 0x20 different, so only a simple subtraction is required to achieve the label conversion. In addition, when displaying English continuously, the data automatic write instruction of T6963C is used to improve the display efficiency.
For the display of a string of Chinese, it is only necessary to implement it by cyclically calling a single Chinese display program. Note that since the string in the C51 language cannot support Chinese, the length of the Chinese string must be manually calculated and passed as a function to this display 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 into the CGRAM when they are needed. This not only improves the display efficiency, but also solves the problem of too small CGRAM.
3.1.3 Graphic Display
In addition to using text to display Chinese characters, graphic display can also be used. 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 special 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. Using text special effects, the optional options and the current options can be indicated by reverse white or flashing effects, making the interface easier to operate.
3.2 Human-computer interaction interface design
In addition to the basic 10 numeric keys, up, down, left, right, confirm, cancel and other keys are also set. In addition, the design of the button position is more in line with people's button habits. The interface uses a hierarchical menu. 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 arrow keys to select functions, and the number keys are only used for data input.
The interface makes full use of text effects. The reverse display of the option indicates that the option has been selected: the reverse flashing of the option indicates that the user can change the option through the arrow keys. In the interface where digital input is required, the cursor can be turned on to indicate the place for digital 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 friendly.
4 Conclusion
This system uses keyboard + LCD input and output devices, and can realize the design of various other peripheral interface circuits through FPGA, reducing the occupation of single-chip microcomputer resources, making the design flexible and convenient. At the same time, FPGA can also provide resources such as memory and I/O ports for the single-chip microcomputer. The circuit designed in this paper has strong scalability. 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 displacement measurement device based on 51 single chip microcomputer and FPGA
Next article:Industrial Sequential Control Based on 8031 Design
Recommended ReadingLatest update time:2024-11-16 19:32
- 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
- msp432 record 1-gpio usage
- [Environmental Expert’s Smart Watch] Part 18: Downhole Mode
- Discussion on the Working Principle of UWB Technology
- The flag bit has been cleared before the general interrupt is turned on, but the interrupt still occurs. How to solve it?
- Keysight Thanksgiving Month | Oscilloscopes are being drawn every day. Recommend and share. More than 100 gifts are waiting for you!
- [Xianji HPM6750 Review 5] LittlevGL transplantation using SPI display
- TI Embedded Live Month - Registration starts now to support efficient, intelligent and low-power system design~
- Four input modes of MCU
- How to replace TMS320C6416TGLZ7 chip
- I would like to ask how to connect the ground on the PCB board of the monitoring equipment and the board ground?