1 Introduction
With the rapid development of the information industry, LCD devices, as one of the information display terminals, have also achieved unprecedented development. Liquid crystal displays (LCDs) have many advantages that many other displays cannot match, such as rich display information, low power consumption, small size, light weight, and ultra-thinness. In recent years, they have been widely used in intelligent instruments, meters, and low-power electronic products controlled by single-chip microcomputers. Configuring a drive circuit for LCD forms a liquid crystal display module (LCM). In addition to LCD and drive circuit, its basic components generally include connectors, backlight sources, etc. The liquid crystal display module has a simple interface like other circuits in the same system, and provides a rich command system for controlling the display. It saves time for the development of the whole machine. The AVR microcontroller is a new 8-bit microcontroller with a reduced instruction set RISC structure launched by Atmel. It has a rich hardware interface. It is manufactured using low-power, non-volatile CMOS technology, and internally integrates three memories with different performance and uses: Flash, EEPROM, and SRAM. In addition to programming the Flash program memory and EEPROM data memory of the AVR microcontroller through the SPI port and a general programmer, most AVR microcontrollers also have the features of ISP online programming and IAP in-application programming. Some high-end AVR microcontrollers, such as ATmega64, ATmegal28, etc., also have MG interfaces. These advantages provide great convenience for the development, design and production of products using AVR microcontrollers.
This paper introduces a method of combining the image dot matrix LCD module CM320240 with the AVR microcontroller ATmega64 to realize the display control of terminal equipment. The design of the hardware circuit and the construction of the system software architecture are given, and a design method of a tree menu interface is explained.
2 System Hardware Design
2.1 Introduction to LCD module CM3XPA0-7 and ATmega64 microcontroller
CM320240-7 is a dot matrix liquid crystal display module (LCM) with Chinese and English text and drawing modes, with a dot matrix of 320*240. It has a built-in 512KB ROM font code, which can display Chinese fonts, digital symbols, English, Japanese, European and other letters. In text mode, it can accept standard Chinese text internal codes to directly display Chinese, without entering the drawing mode to describe Chinese, which can save a lot of microprocessor time and improve the processing efficiency of LCD display Chinese. ATMaga64 is a high-end AVR microcontroller with rich hardware resources.
(1) Advanced RISC architecture, 130 instructions, most of which are executed in a single clock cycle, 32 8-bit general-purpose working registers. Fully static operation, performance up to 16MIPs at 16MHz, and a hardware multiplier that only requires two clock cycles.
(2) Non-volatile program and data memory. 64K bytes of system programmable Flash, optional Boot code area with independent lock bit, through the on-chip Boot program to achieve real read and write simultaneous operation of 2K bytes of EEPROM, 4K bytes of on-chip SRAM, 64K bytes of optional external program storage space, the lock bit can be programmed to achieve user program encryption.
(3) JTAG interface (compatible with IEEE1149.1 standard), boundary scan function compliant with JrI'AG standard, supports extended on-chip debugging function, and can realize programming of Flash, EEPROM, fuse bits and lock bits through the JTAG interface.
(4) Rich peripherals, two 8-bit timer/counters with independent prescaler and comparator functions. Two 16-bit timer/counters with prescaler, comparison function and capture function. Real-time counter RTC with independent oscillator, two 8-bit PWM channels. 8-channel 10-bit ADC, byte-oriented two-wire interface, fully compatible with 12C. Two programmable serial USARTs, SPI serial interface that can work in master/slave mode. Programmable watchdog timer with independent on-chip oscillator.
(5) It also has some special processor features: power-on reset and programmable power-off detection, on-chip calibrated RC oscillator, software-selectable clock frequency, and six sleep modes.
2.2 System Hardware Composition
The system hardware platform mainly consists of three parts: MCU, human-machine interface (LCD module and keyboard), and communication interface. The system block diagram is shown in Figure 1.
Figure 1 System hardware block diagram
The standard UART serial port communication is used between the single-chip microcomputer and the device host. The hardware connection is relatively simple, and only a TTL to RS232 level conversion chip is needed.
For the keyboard, we use a commonly used six-key keypad, namely Enter, Return, Up, Down, Left, and Right. Since the ATmega64 microcontroller has rich I/O resources, with a total of 53 programmable I/O ports, and we use a six-key keyboard, we can directly connect the keys to the I/O ports. If more key switches are used, a matrix keyboard can also be used to save I/O, which will not be described here. The I/O port of the AVR microcontroller has a pull-up resistor, so we do not need to add an external pull-up resistor. We only need to enable the pull-up resistors of these key interfaces during software initialization. Ground one end of each key, and connect the other end to a NAND gate in addition to connecting to the PC0-PC5 ports respectively. The output pin of the NAND gate is connected to an external interrupt of the microcontroller. In this way, when any key is pressed, the output of the NAND gate changes from low to high, causing the microcontroller to generate an interrupt. Therefore, you can use the query method for keyboard operation or the interrupt method, which increases the design flexibility.
CM320240-7 LCD module supports 8080 and 6800 series MCUs, and also provides 4-bit or 8-bit data bus interface. Here we use 8-bit data bus interface in 8080 mode. The biggest difference between 8080 series MCU and 6800 series MCU is that the control signals of read and write are separate. When RD is low, the read action is performed, and when WR is low, the write action is performed. There are some differences when MCU reads and writes the command register and DisplayRAM of the LCD module: if the register is read and written, the MCU must first send the address of the register through the data bus, and then read and write the register data on the data bus; if the DisplayRAM is read and written, the MCU can directly read and write the DisplayRAM data on the data bus. It should be noted that: during initialization, the read and write control signals must be set high first, and the read and write operations are disabled, otherwise it will cause the subsequent timing disorder. Even if the subsequent read and write procedures are correct, the LCD module will not have any display. Even if the IO pins of the AVR microcontroller are not used, they must be given a certain state during initialization, otherwise problems may easily occur.
The eight-bit data bus of the LCD module is directly connected to the PA port of the microcontroller, and several control pins are connected to the common IO of the microcontroller. It is worth noting that the contrast of the LCD module must be controlled between the LCD drive voltage input terminal V0 and the LCD drive voltage output terminal VEE. An adjustable resistor with a resistance of about 20K must be connected between the LCD drive voltage input terminal V0 and the LCD drive voltage output terminal VEE to adjust the contrast of the LCD module. The VEE output is fixed at -23V.
Through practice, the best effect is when the Vo input is about -18V. We hope that the LCD backlight is turned off to save power when not in use, and wake up when the keyboard is operated. Therefore, a switch tube control is added to the input end of the LCD module backlight power supply. The interface circuit between the LCD module and the ATMaga64 microcontroller is shown in Figure 2.
Figure 2 LCD module interface circuit
3 System Software Architecture
The integrated development environment used for software development of AVR microcontrollers is AVR Studio provided by Atmel. In order to use C language for software development, a C compiler must be installed separately. There are many C compilers for AVR at present, and the commonly used ones are GCC (ie WINAVR), ICC, IAR and CodeVisionAVR. Among them, GCC is a free software with open source code. There is no need to consider the price factor when using it. Therefore, whether it is GCC itself or the AVR compilation package that comes with CCC, its update speed and efficiency are unmatched by other development tools. The source program written in GCC has high readability and portability. The software development involved in this article is to use AVR Studio and GCC.
3.1 System Software Overall Framework
The function of the entire terminal display and control system is to display the internal working conditions of the equipment and set some parameters, so the most important thing is the data interaction between the display and control system and the equipment host and the beautiful and comfortable human-computer interaction interface. Data interaction and interface switching must also be coordinated with keyboard operation. At the same time, a sleep mode should be added, that is, the backlight can be turned off when there is no operation, and some modules can be turned off. When the user uses the keyboard, a keyboard interrupt is generated to wake up from the sleep mode. Therefore, we can determine the basic architecture of the system software, as shown in Figure 3.
Figure 3 Main program flow chart
3.2 Software Design of Tree Menu Interface
It can be seen that the overall framework of the system software is relatively simple, and the focus is on how to interact with the device host and coordinate the menu display. Below we will introduce a software design of a tree menu interface. This method regards the entire menu as a tree structure, and each menu interface is a node on the menu tree: its parent node is the upper level menu of the current menu, and the child node is the first submenu of the current menu; the left and right nodes are the "brother" menus of the current menu, that is, the remaining submenus of its upper level menu.
Number each node, define a long integer D as the node number, the root node D=1, considering that some nodes have more than 10 submenus, the submenu is the parent menu ID multiplied by 100 plus the corresponding sub-item ID (1, 2, ...) of the submenu in the upper menu, so that the ID of the first-level submenu is 101, 102, 103. The sub-level ID corresponding to IDl01 is 10101, 10102, 10103..., so that different key operations correspond to different menu node search methods, that is, each time you only need to modify the global node number ID. We can also define several global variables to represent the number of submenus, adjacent menus and menu types of each level of menu, so that we can switch between menus more conveniently. The program flow of keyboard-coordinated menu switching is shown in Figure 4.
Figure 4 Menu selection program flow
4 Conclusion
Nios II is a cost-effective embedded processor. Combining it with flOPC technology can provide an efficient, flexible and low-cost solution for peripheral interface design. In addition, Nios II also provides custom instruction functions. It is precisely because of the many advantages of Nios II and SOPC technology that reconfigurable embedded systems can be developed in a relatively short period of time. The design method combining Nios II and SOPC technology has become a competitive solution in embedded systems. This method can be used in many fields and therefore has broad application prospects.
Previous article:Design of indoor lighting control system based on Atmega16
Next article:VGA Display Technology Based on ARM Processor S3C2440
Recommended ReadingLatest update time:2024-11-16 16:47
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- 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
- Tips for selecting inductors in switching power supplies
- Watch! Millimeter wave applied to liquid level measurement design case,,,
- Can anyone share the motor stall detection circuit? Similar to the motor stall detection circuit of door locks and sweepers,
- STM32F10x stepper motor encoder position control CANWeb source program
- MSP430F249_TimerA timer
- Synthesizable Verilog Syntax (Cambridge University, photocopy)
- [RVB2601 Creative Application Development] Short recording, playback and printing of recording data
- When the carrier data reaches the receiving end, how does the receiving end identify this information?
- SparkRoad Review (7) - FPGA Serial Port Test
- Disable AD auto-start JLink