Application Technology of LPC2132 in Embedded System

Publisher:zuiquanLatest update time:2012-05-21 Source: 微计算机信息 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

SoC has a broad application prospect in medical devices [1]. LPC2131/2132/2138 is a microcontroller based on a 32/16-bit ARM7TDMI-STM CPU that supports real-time simulation and embedded trace, with 32kB/64kB/512 kB embedded high-speed Flash memory and 8/16/32kB on-chip static RAM. Up to 47 5V general-purpose I/O ports, 1 (LPC2132/2132) or 2 (LPC2138) 8-channel 10-bit A/D converters with a total of 16 analog inputs, and 1 10-bit D/A converter that can provide different analog outputs (LPC2132/2138). Multiple serial interfaces, including 2 16C550 industrial standard UARTs, 2 high-speed I2C interfaces (400kbit/s), SPITM and SSP. Internally integrated real-time clock and other resources make them particularly suitable for embedded systems such as industrial control and medical. This article takes LPC2132 as an example to introduce the design experience and design technology of LPC2132.

2. Display Design

Display design is an important part of all embedded systems. Display devices include LED, character LCM, graphic LCM, VFD, etc. Graphic LCM (such as 128x64, 192x64 dot matrix) can display ASCII characters, Chinese characters and graphics, and has a high cost performance. It is increasingly widely used in embedded systems. Although the design in the MCS-51 series is very mature. However, since there are many differences between ARM and MCS-51, their design methods are of course different. The following takes LPC2132 and 192x64 dot matrix LCM as an example to illustrate.

2.1 Hardware interface design with liquid crystal display module (LCM)

1) Level matching: The operating voltage range of the LPC2132 series is 3.0~3.6 V. There is no problem in choosing a 3V LCM, but the price of a 3V LCM on the market is often more expensive than a 5V LCM. The I/O port of the LPC2132 can withstand a maximum voltage of 5V, so a 5V LCM can be used, but a 5V pull-up resistor must be connected to the I/O port connecting the LCM and the LPC2132.

2) I/O connection: LPC2132 has no external bus, and all I/O ports need to be configured. The internal registers determine whether they are input or output. Among them, P0 port has 31 I/O ports, P1 port has 16 I/O ports, and the I/O port numbers are not continuous (such as P0.28 and P1.25 are adjacent). Since the I/O ports are operated by bits during programming, the specific connection can be made according to the hardware circuit board wiring requirements. In order to increase the display refresh speed, it is necessary to detect the busy flag inside the LCM. Before writing data to the LCM each time, read the status of the LCM first. Only when the status is not busy can the display data be written. In this way, it is necessary to pay attention to dynamically set the direction of the LPC2132 I/O port connected to the LCM data line, and the 8 data bits must be controlled one by one using IOSET and IOCLR.

3) LCD backlight control: Since the backlight current of the LCD requires more than 100 mA and the voltage is generally around 5 V, and the I/O port driving capability of LPC2132 is relatively weak, using the driving circuit in Figure 1, LPC2132 can reliably control the on and off of the backlight LED without interfering with the system.

Figure 1 LCD backlight control circuit

2.2 LCD display software design

LPC2132 can use CodeWarrior for software development. Since it is programmed in C language, the development speed is relatively fast. When writing LCM program, first write the hardware driver, including LCM initialization function, write LCM data function, write LCM command function, read LCM data function, read LCM command function. Based on these functions, write the function of displaying 16x16 dot matrix Chinese characters, set the display position function, etc. Due to space limitations, I will not go into details here. The following focuses on introducing readers to the skills of displaying Chinese characters and improving the refresh speed of LCD display.

When displaying Chinese character information, you need to first use tool software to extract the dot matrix of the Chinese characters to be displayed, and save the dot matrix information in the program. If you only use C language, you can only define array variables, and then call the defined array variables when displaying. However, this method has the following disadvantages. 1) Using array variables to define character dot matrix will waste precious RAM resources. 2) When the display content is rich and a large amount of dot matrix data needs to be defined, it will cause insufficient RAM capacity. If you use assembly language files and C language files for mixed programming, the character dot matrix information is saved in the form of program code and does not occupy RAM, the above problems can be overcome. The following takes the display of the Chinese character "Shanghai" (16x16 dot matrix) as an example to introduce the specific method:

1) Definition of dot matrix information.

Create an assembly language file with the extension s. The file contents are as follows.

EXPORT shang16x16

EXPORT hai16x16

AREA TTTT,CODE,READONLY

ENTRY;

shang16x16

DCB 0,0,0,0,0,0,255,32

DCB 32,32,32,48,32,0,0,0

DCB 6,16,16,16,16,16,31,16

DCB 16,16,16,16,24,16,0,0

hai16x16

DCB 16,33,198,144,136,247,148,180

DCB 212,148,148,246,132,128,0,0

DCB 2,62,1,0,12,11,8,9

DCB 10,40,56,15,8,0,0,0

END

The above file defines the Chinese character dot matrix information of "Shanghai". Add this file to the project file. After compilation, the dot matrix information is stored in FLASH as program code.

2) Declaration of dot matrix information.

Create a header file with an extension of h to declare the character lattice information defined in the assembly language file so that other programs in the project can use the defined lattice information, such as lattice.h. The specific contents of the file are as follows:

extern unsigned char shang16x16[];

extern unsigned char hai16x16[];[page]

3) Reference to dot matrix information.

Insert this header file into other files. For example, suppose the function void WR_LCM16x16(unsigned char x_row,unsigned char y_col,unsigned char *p_matrix) is to display the character matrix pointed to by p_matrix starting from the position of x_row and y_col. Then WR_LCM16x16(2,0,shang16x16) and WR_LCM16x16(2,16,hai16x16) can display "Shanghai".

The refresh speed of LCD display is a key technology in LCD application. The author has explored the following methods to greatly improve the display refresh speed.

1) Make full use of the busy flag of LCM to reduce the read and write interval. For example, the interface of 192x64 LCD modules contains a busy flag. If you simply insert a certain delay between two read and write intervals, the waiting time will be longer and the refresh will be slower.

2) Information classification to reduce repeated refreshes. The entire screen can be divided into a blank area, a fixed information display area, and a dynamic information display area. For example, parameter names, units, etc. can be classified as fixed information, while real-time data can be classified as dynamic information. The fixed information area is refreshed only when entering a certain screen for the first time, and only the dynamic information area is refreshed at other times.

3) Establish data update mark to further reduce the workload of dynamic information refresh. Establish a display buffer in the memory for each dynamic information, and only those items of dynamic information that have changed need to be refreshed.

The comprehensive application of the above methods can greatly improve the display refresh speed.

3. System parameter power-off preservation technology

Since there is no EEPROM in the LPC2132 chip, all parameters will be lost when the system loses power. If there are many parameters to be saved, the system can only be expanded with an EEPROM chip such as 2402. However, if the data to be saved is small (for example, less than 10 bytes), the system's real-time clock register resources can be used instead of expanding the EEPROM to reduce product costs. This is described in detail below.

The real-time clock of LPC3123 has an independent power supply circuit, and the dedicated power supply pin can be connected to a battery or a 3.3V voltage. In product design, it is generally powered by a battery to maintain uninterrupted operation of the clock. LPC2132 has a complete time register. However, in the design process, not all registers are needed. For example, some of the alarm registers such as year, month, day, hour, minute, second, and week are not used during the design. As long as the unused alarm registers are shielded when setting the alarm shield register, the data of the corresponding alarm register will have no effect on the alarm. These registers can be used to save data. As long as the clock power supply is maintained, the data will not be lost.

LPC2132 has two high-speed I2C interfaces. When the amount of data to be stored is large, you can connect the 24xx series EEPROM chip to the I2C interface. Before use, configure the relevant pins to make it have I2C bus function. In addition, when using I2C interrupt, you must also turn on the corresponding interrupt, which is more convenient to use. However, when using I2C, you must pay attention to the necessary time interval between two consecutive I2C bus reads or writes, that is, you must wait until the previous bus ends before restarting the bus, otherwise an error will occur.

4. Other application technologies

When designing hardware, please note that the input current of the I/O port of LPC2132 is greater than the driving current. When driving the LED, you can consider using the current injection technology (the LED is on when the I/O port outputs a low level). If this method still cannot meet the requirements, you can use multiple I/O ports in parallel or add a driving circuit.

LPC2132 has an internal 8-channel 10-bit A/D converter, but when using it, the I/O port must be protected by a voltage regulator diode to prevent the input analog value from exceeding the limit and damaging the chip.

When designing software, please note: Try to use the bit operation instructions IOSET and IOCLR to control the I/O port of LPC2132, instead of directly operating the I/O port register (such as IO0PIN or IO1PIN), otherwise unpredictable results will occur.

Please note when debugging: LPC2132 supports JTAG debugging, but because JTAG uses the system's timer T0, when the user uses JTAG for software debugging, timer T0 cannot be used, otherwise an error will occur.

5. Application Examples

The author designed the controller of the biosafety control cabinet with LPC2132 as the core. The biosafety control cabinet is a medical disinfection instrument. Medical equipment is placed in the safety control cabinet and sterilized by ultraviolet light. When the disinfection is completed, in order to prevent the virus that is not killed by ultraviolet light from floating out of the cabinet, it is required to start the blower and exhaust fan when the cabinet door is opened. The blower replenishes fresh air from the outside and sends it into the safety control cabinet after passing through the filter. The exhaust fan filters the internal bacteria air and discharges it to the outside. And ensure that a certain negative pressure is maintained in the safety control cabinet.

The safety control cabinet has two working modes: operation mode and disinfection mode. In the operation mode, the door opening and closing actions are allowed, the lighting and external power sockets are allowed to be controlled, but the UV lamp is prohibited to be turned on, and the air supply and exhaust fans are automatically started as long as the door is opened, and the air supply and exhaust fans are automatically stopped as long as the door is closed; in the disinfection mode, only the UV lamp switch action, the lighting and external power socket control are allowed, and the door opening and fan start actions are prohibited.

The system is required to display the disinfection progress, the wind speed of the supply and exhaust fans, and the filter differential pressure value in real time. When the supply wind speed is greater than the exhaust wind speed, the front door is opened during disinfection, the filter is ineffective, etc., an alarm will be issued. In addition, the current clock, etc. need to be displayed.

The system is also equipped with fans, UV lamps, lighting, sockets, door opening, door closing, UP, DOWN, LEFT, RIGHT, and ENTER buttons to control corresponding operations and parameter settings, etc. Figure 2 is a structural block diagram of the biosafety control cabinet.

Figure 2 Biosafety control cabinet structure diagram circuit

As can be seen from Figure 2, the entire system only requires a small amount of peripheral circuits and drive circuits, and the performance-price ratio is relatively high. Specific implementation method: Use HONYWELL's 24PC series pressure sensor to measure and control the internal pressure, and send it to the internal A/D conversion module of LPC2132 after amplification by the amplifier circuit to achieve A/D conversion. According to the detected pressure data, the wind speed and internal pressure state of the fan are calculated, and corresponding actions are performed. The display uses 192x64 graphic LCM, which displays a large amount of information. The full Chinese interface is very convenient for users to operate.

6. Conclusion

The author's innovations are: designing the hardware interface circuit between LPC2132 and liquid crystal; proposing a mixed programming method of assembly language and C language; exploring design techniques to improve the refresh speed of liquid crystal displays; introducing parameter preservation techniques and other application technologies in the LCP2132 system; and successfully applying these technologies to specific product designs.

References

[1] Li Hao, Ma Wenli, et al. Design of embedded medical detection equipment platform based on SoC chip, Microcomputer Information, No. 7-2, 2005: pp. 63-64

[2] LPC2131/2132/2138 User Guide, http://www.zlgmcu.com

[3] Li Weiti, Guo Qiang. Liquid Crystal Display Technology[M]. Beijing: Electronic Industry Press, 2000

Reference address:Application Technology of LPC2132 in Embedded System

Previous article:Embedded multi-channel voice recorder based on AC48304
Next article:USB camera image acquisition based on ARM920T under Linux

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号