Terminal display and control design based on AVR microcontroller

Publisher:RadiantJourneyLatest update time:2012-11-22 Source: 维库电子Keywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:AVR Reference address:Terminal display and control design based on AVR microcontroller

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

Design of modular detection system based on AVR microcontroller TWI
Introduction With the continuous improvement of the informationization and intelligence of equipment, communication between devices has become increasingly important. At present, most of the communication between devices, especially the communication between multiple devices, is realized by various standard buses. Re
[Microcontroller]
Design of modular detection system based on AVR microcontroller TWI
AVR MCU pwm program + simulation_digital display
  #include iom16v.h #define uchar unsigned char #define uint unsigned int uchar Table ={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x79}; float Data1 ={10,0,5,0}; float Data2 ={3,9,1,0}; float Key1,Key2; void DelayMs(float i) {         flying j;         for(;i!=0;i--)         {                 for(j=150;j
[Microcontroller]
AVR MCU pwm program + simulation_digital display
Why choose AVR microcontroller?
What is an AVR microcontroller? What are the advantages of an AVR microcontroller? Why should you choose an AVR microcontroller? AVR microcontroller is a new type of microcontroller developed by ATMEL. Compared with 51 microcontroller and PIC microcontroller, it has a series of advantages: 1: AVR runs fastest under
[Microcontroller]
Advantages and features of AVR microcontrollers and future development prospects
This article discusses the specific applications of single-chip microcomputers in life, tells the development history and characteristics of single-chip microcomputers, and looks forward to the prospects of single-chip microcomputers. With the continuous development of urban public transportation, unmanned ticket bu
[Microcontroller]
Advantages and features of AVR microcontrollers and future development prospects
AVR IO structure analysis and operation
Analysis and operation of AVR IO structure AVR IO is a true bidirectional IO structure. Since most netizens are from the standard 51, they are affected by the quasi-bidirectional IO and Boolean operation concepts of the standard 51 and have not been able to master the IO operation of AVR, so it is necessary to write
[Microcontroller]
Production of ISP Download Cable for AVR Microcontroller
The function of the microcontroller programmer is to burn the debugged program into the memory of the microcontroller. The cost of the AVR microcontroller ISP download cable introduced in this article is only about 10 yuan, which is very suitable for beginners to make it themselves. The program of AVR microcont
[Microcontroller]
Production of ISP Download Cable for AVR Microcontroller
What are the characteristics of AVR microcontrollers?
What is an AVR microcontroller? What are the advantages of a VR microcontroller? Why should I choose an AVR microcontroller? AVR microcontroller is a new type of microcontroller developed by ATMEL. Compared with 51 microcontroller and PIC microcontroller, it has a series of advantages:
[Microcontroller]
GSM Wireless Intelligent Transformer Integrated Alarm System Based on AVR
1. Project Overview 1.1 Introduction The GSM wireless intelligent transformer integrated alarm system based on AVR designed in this project aims to provide a wireless intelligent transformer integrated alarm system that can identify system power outages and prevent false alarms; can measure transformer oil tempera
[Microcontroller]
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号