Watchdog circuit is one of the anti-interference measures needed by embedded systems. This paper designs a new watchdog circuit using X25045 chip, which has the characteristics of small size, less I/O port lines and convenient programming. It can be widely used in instruments and various industrial control systems.Preface When the industrial control system is running, it will usually encounter various on-site interferences. Anti-interference ability is an important indicator to measure the performance of the industrial control system. The watchdog circuit is an important guarantee for the operation of the self-monitoring system. Almost all industrial control systems contain a watchdog circuit. In the 8096 series microcontrollers and enhanced 8051 series microcontrollers, the system has been built into the chip. Users only need to open it with software, which is very convenient to use. However, the current industrial control system is still using the cheap ordinary 8051 series microcontrollers, so the watchdog circuit must be established by the user himself. There are two types of watchdog circuits: software watchdog and hardware watchdog. Software watchdog does not require external hardware circuit, but the system needs to give up a timer resource, which is difficult to do in many systems, and if the system software does not run properly, it may cause the watchdog system to be paralyzed. Hardware watchdog is a true "program operation monitor". For example, the counting watchdog circuit is usually composed of a 555 multivibrator, a counter, and some resistors, capacitors, etc. The system circuit composed of discrete components is relatively complex and the operation is not reliable enough. X25045 Chip Introduction X25045 is a standardized 8-pin integrated circuit produced by Xicor Corporation of the United States. It combines three functions of EEPROM, watchdog timer and voltage monitoring in a single chip, which greatly simplifies the hardware design, improves the reliability of the system, reduces the space requirements for printed circuit boards, reduces costs and system power consumption, and is an ideal single-chip peripheral chip. The pinout of X25045 is shown in Figure 1. Figure 1 X25045 pin diagram Its pin functions are as follows. CS: chip select input; SO: serial output, data is output bit by bit from this pin; SI: serial input, data or command is written bit by bit from this pin to X25045; SCK: serial clock input, its rising edge writes data or command, and its falling edge outputs data; WP: write protection input. When it is low level, the write operation is prohibited; Vss: ground; Vcc: power supply voltage; RESET: reset output. Before the X25045 reads and writes, it needs to send instructions to it. The instruction name and instruction format are shown in Table 1. Table 1 X25045 instructions and their meanings Design and programming of X25045 watchdog circuit The X25045 hardware connection diagram is shown in Figure 2. The X25045 chip contains a watchdog timer, which can preset the system monitoring time through software. If there is no bus activity within the preset time of the watchdog timer, the X25045 will output a high-level signal from RESET, and output a positive pulse through the differential circuit C2 and R3 to reset the CPU. In the circuit of Figure 2, there are three CPU reset signals: power-on reset (C1, R2), manual reset (S, R1, R2) and watchdog reset (C2, R3), which are added to the RESET terminal after being synthesized through the OR gate. The time constant of C2 and R3 does not need to be too large, and hundreds of microseconds are sufficient, because the CPU oscillator is already working at this time. Figure 2 X25045 watchdog circuit hardware connection diagram The preset time of the watchdog timer is set by the corresponding bit of the status register of X25045. As shown in Table 2, there are 6 bits in the status register of X25045, of which WD1 and WD0 are related to the watchdog circuit, and the remaining bits are related to the working settings of EEPROM. Table 2 X25045 status register WD1=0, WD0=0, preset time is 1.4s. WD1=0, WD0=1, preset time is 0.6s. WD1=1, WD0=0, preset time is 0.2s. WD1=1, WD0=1, disable watchdog. The length of the watchdog circuit timing time can be determined by the cycle of the specific application program, and is usually slightly longer than the maximum cycle time when the system is working normally. When programming, you can add a dog feeding instruction in the appropriate place of the software so that the watchdog timing time will never reach the preset time, and the system will not reset and work normally. When the system runs away and the program cannot be captured back by software traps or other methods, the watchdog timing time will quickly increase to the preset time, forcing the system to reset. The following is part of the watchdog program written in C language. #include "reg51.h" sbit cs=P1^2;/*Chip select signal is generated by P1.2*/ sbit sck=P1^3; /*Clock signal is generated by P1.3*/ sbit si=P1^0; /*SI is generated by P1.0*/ sbit so=P1^1; /*SO is generated by P1.1*/ sbit c=ACC^7; /*Define bit variables*/ bdata unsigned char com; void tran() /*Send one byte data sub-function*/ { unsigned char i; for(i=0; i<8; i++) { ACC=com; /*Put data into a*/ si=c; sck=0; /*sck generates an up jump*/ sck=1; com=com<<1; /*Shift left one bit*/ } return; } main() { com=0x06; /*Send write and read enable command*/ cs=0; tran(); cs=1; com=0x01; /*Send write status word command*/ cs=0; tran(); com=0x00; /*Timing 1.4s*/ tran(); cs=1; ...;Program part for normal system operation } It should be noted that when the program is running normally, a dog feeding instruction should be added in an appropriate place so that the timing time of the system during normal operation does not reach the preset time. The system will not reset. The dog feeding instruction is as follows. main() { ...; The program part for normal system operation { cs=0; /*Generate cs pulse*/ cs=1; } } The watchdog circuit of X25045 is very convenient to use. X25045 also integrates 512BEEPROM and voltage operation monitoring system. Only one chip, plus crystal oscillator and reset circuit can form a single-chip microcomputer application system, which is very suitable for the design of portable instruments and embedded systems. References 1. Li Chaoqing. Principles and Control Technology of Single Chip Microcomputers. Beijing University of Aeronautics and Astronautics Press, 2001 2. Hu Wei, Ji Xiaoheng. Single Chip Microcomputer C Program Time and Application Examples. People's Posts and Telecommunications Press, 2003 3. American Xicor Company x25045 Data 开始插入图片 admin20060217113703.jpg admin20060217113713.jpg admin20060217113915.gif admin20060217113924.gif 结束插入图片
|