1 Introduction
The single-chip application system has a simple structure, high reliability, strong flexibility, and high performance pricing, and has now been widely used in various fields in the computer industry. With the promotion of single-chip applications, the maintenance issues of single-chip systems should be directly used, especially in the management of multiple versions of software under the same hardware structure, there is also a need for online maintenance of single-chip microcomputer systems.
2 system design principle
There are two cases of online maintenance of the single-chip system, one is to divide the system into two parts, and are loaded into the EPROM of the microcontroller with Flash, such as AT89C52, etc., because EPROM generally needs to be programmed by specialized programming instruments Therefore, it is generally not changed online; however, since Flash can be rewritten online, the online maintenance of the microcontroller system can be realized by online programming of Flash. At this time, the Flash chip can also be seen as an extended program memory. Another situation is a chip with a program loading function, such as TMS320VC33, TMS320F206, etc., which are loaded from Flash when the system is started, and the program can be maintained for the system as long as the program is dynamic to the FLASH.
This paper uses ATMEL's AT89C52 single-chip microcomputer as an example, using serial communication, the implementation of online maintenance of single-chip microcomputer systems is elaborated. In the system, the program is loaded in the AT89C52 and Flash, respectively, in the case where the procedures remain unchanged in the AT89C52, can dynamically update the programs in the flash depending on the needs of the system. The program in the AT89C52 is the following structural relationship with the procedure in Flash.
Figure 1 AT89C52 and FLASH program structure
In the above figure, the program in the AT89C52 is usually referred to as the boot program, and the program in the flash is called a loader. The bootstrap should have basic functions, such as initialization, system utility, interrupt vector definition, etc., there is also a function of loading programs (with the ability to serve serial communication, and read / write the Flash chip). When maintenance, the .bin program file is sent to the AT89C52 through the PC serial port, and the AT89C52 receives the data and writes it into the Flash chip, so as long as the BIN program file can be maintained for the software of the microcontroller system.
3 hardware structure illustration and description
The hardware circuit is shown in Figure 2.
Figure 2 interface circuit of AT89C52 and SST29EE010
In the reverse connection address line A15 of the SST29EE010 in Fig. 2, it can be selected when the MCU generates 8000H ~ 0FFFFH addressing range, and the SST29EE010 chip has a 2AAAH, 5555H address value of the lock-write operation. It is also necessary to add 8000 hours (relevant SST29EE010 chip unlocking, switching control, please refer to "MCU and Embedded System Application" 2003 No. 8 P31-32).
The SST29EE010 space size is 128K bytes, and the maximum addressing space of the AT89C52 is 64K. This article does not consider the problem of expanding, directly connecting the high address A15, A16, only using the SST29EE010 chip's 128K byte space of 0000H ~ 7FFFH 32K space. To utilize more space, you need to expand your addressing.
4 software design and development
The development of system software includes two aspects: the development of the boot program and the development of the loader. The development of the boot program is the basis of the system. The main function is to implement the initialization of the MCU, memory check, FLASH availability check, serial communication function implementation, and the loading of the Flash program and the error alarm, and the workflow of the boot program is shown in Figure 3. Indicated.
Figure 3 Guide program workflow chart
There are four important parts of the boot program, the AT89C52 initialization, the serial interrupt service program, and the implementation of the program load instruction, and the resolution of the command code. The boot program is waiting to be loaded before the system is not loaded, until the load is completed, and when the boot program enters the normal mode of operation, it can also be programmed by calling the program load module (subroutine). renew.
Since the SST29EE010 is written in a 128-byte page manner, the write operation of the SST29EE010 is packetized to 128 bytes of packets, less than 128 bytes of packets. When loading the program, the host will load the load program .bin file in units of 128 bytes, and add the upgrade command code and location parameters to each packet to send it to the MCU, and the MCU receives the data. If it is loaded instruction The received data is written to the Flash area specified by the parameter and returns the operation code; the processing flow is shown in FIG.
Figure 4 process flow chart loaded
5 precautions
Pay attention to the following points during system design and program design:
(1) When the Flash chip is read / write, it is used as an extended external memory (with the MOVX @ DPTR, A command); when executing the program, it is used as an extended program memory.
(2) Open the protection lock of the SST29EE010 before writing data, and then turn off the SST29EE010's protection lock to close, and there is a certain delay before the lock (10ms required).
(3) In order to ensure the available row of the entire system, the simpler method is required to increase the line detection mechanism for the loader, add 3 bytes of content to the .bin file, add 2 bytes in front of the file. BIN The length indication of the file, and adds 1 byte of the program check value (such as different or value) after the loader, the content written in the flash is shown in Figure 5.
Figure 5 Loader format and content
(4) In order to further improve the security of the system, the authority of the relevant identity authentication is required, such as password verification, otherwise it will not open the load function.
(5) You should also add some of the version controls and check functions, and the version is controlled, and only program load can only be loaded when the AT89C52 has the same version with the same version to be loaded.
(6) Because the loaded program start address starts from 8000h, there is a length indication of 2 bytes, so adding "ORG 8002H" pseudo instructions before loading the program.
6 Conclusion
More and more demand based on single-chip microcomputer, there is more maintenance issues. It is convenient to maintain more maintenance through the upper application maintenance. Based on the idea of realizing online maintenance of single-chip microcomputer systems, this paper introduces a method of maintaining a microcontroller system through a PC serial interface, providing a very convenient means for version management, dynamic maintenance of the program, and extension of program memory. , Reading the full text, the technology area
Fiber interface adapter effectively solves research and implementation of high data transmission
How to realize online maintenance of single-chip system?
Multi-channel data acquisition system hardware implementation scheme based on AD0809 and single chip microcomputer
What are the differences between threads and processes?
How to design a reliability single-chip reset circuit? What should I pay attention to when designing?
Our other product: