0 Introduction
The working stability and reliability of instruments and meters with single-chip microcomputer as the core are often greatly affected by the working environment. When the electromagnetic interference is weak (such as indoors), the reliability and stability are often easy to meet the application requirements. However, outdoors, especially in the case of harsh working environment, it is possible that the instrument and meter will not work properly or fail. Therefore, it is of great practical significance to use the advantages of single-chip microcomputer itself and rich peripheral modules to improve the anti-interference ability of instruments and meters.
At present, the solution to the single-chip microcomputer program runaway is mainly achieved by using the open dog. When solving the power-off data protection function, two types of data storage media are often used: one is EEPROM, but the writing time is long; the other is a small-capacity SRAM with a backup battery to form a non-volatile memory. This method has a fast writing speed, but increases the complexity of the circuit.
SST's FlashFlex51 series of single-chip microcomputers have internal watchdogs and on-chip Flash memory, which can be used to solve the problems of single-chip microcomputer program runaway and power-off storage of important data. This paper uses SST89E58RD2 single-chip microcomputer of SST company to solve the problem of program running away and superimposed characters lost in video character overlay system under harsh environment.
1 Analysis of the problem of video character overlay system
The character overlay effect of the video character overlay system in indoor environment can generally meet the application requirements. However, when the system is applied to the outdoor environment with serious electromagnetic interference, the overlay system often has problems such as the disappearance of overlay characters and abnormal communication between the system and the host computer. Through the analysis and research of this problem, it is found that the real reason why the system cannot operate normally is that the microcontroller program runs away and the video memory content of the character overlay chip in the overlay system is cleared when it is disturbed by the outside world. Since the hardware structure of the system is generally not easy to change, finding a microcontroller that is compatible with the current AT89C51 and can solve the system instability is the best way to solve the problem. After comparing and analyzing the AT89C51 microcontroller and other 51 microcontrollers, this paper selects the SST89E58RD2 microcontroller to solve the problem of system stability and reliability.
2 Introduction to SST89E58RD2
2.1 Main features of SST89E58RD2
The SST89E58RD2 microcontroller is compatible with the 80C51 series microcontrollers and has a built-in super FLASH memory. The operating frequency is 0 to 40 MHz at a 5 V operating voltage, which is fully compatible with the current 80C52 series microcontroller hardware PIN-TO-PIN, and the software and development tools are also fully compatible; the SST89E58RD2 has 1 K bytes of internal RAM and contains a 32 K bytes basic storage block and an 8 K bytes secondary storage block of super FLASH; it has ISP (in-system programming) and IAP (in-application programming) functions; the chip has SPI (serial peripheral interface) and enhanced UART, 10 interrupt sources, four interrupt priorities and a programmable watchdog timer (WDT); it is compatible with TTL and CMOS logic levels; it contains a built-in PCA (programmable counter array) with PWM and capture and comparison functions; it can realize power-off detection.
2.2 Watchdog Timer
The built-in programmable watchdog timer of SST89E58RD2 can be used for automatic recovery when the program is in a dead loop or the program is not running normally (such as the program is running away). In order to protect the system from abnormal operation caused by program dead loop, the user program needs to refresh the watchdog timer within its defined period, otherwise, when WDRE (watchdog reset) is valid, it will trigger an internal hardware reset. WDT (watchdog timer) uses the system clock as the reference clock. Therefore, strictly speaking, the watchdog timer should be called a watchdog counter. The WDT register is incremented by 1 every 344064 system clocks. The watchdog data/reload register (WDTD) serves as the reload register of WDT. The structural block diagram of WDT is shown in Figure 1. The watchdog can work through two special registers WDTC (watchdog timer control register) and WDTD. In idle mode, the WDT operation is temporarily suspended and resumes from idle mode to normal working mode after receiving an interrupt signal. The calculation formula of WDT counting period is as follows:
Period = (255-WDTD) x 344064 x 1/Fclk
, where WDTD is the reload value placed into the WDTD register, and Fclk is the crystal frequency of the system.
3 FLASH Memory Programming
The SST89E58RD2 microcontroller can use the IAP mode to erase or write data to its internal FLASH memory. When the CPU of the SST89E58RD2 microcontroller enters the IAP mode, one of the two areas of its FLASH memory can be erased or written while the user code in the other area can still be executed by the CPU. That is, while writing data to the internal FLASH memory, the CPU can load code from the external memory. The special function registers SFST, SFCM, SFAL, SFAH, SFDT, and SFCF located inside the microcontroller are used to control and manage the erasing and programming execution of the FLASH. In the IAP mode, the CPU core and the FLASH control unit will turn off the external clock, and the internal crystal oscillator provides the timing reference for the programming and erasing operations. The internal crystal oscillator is turned on only when requested and is turned off immediately after the FLASH operation is completed. For the CPU to run in the IAP mode, the IAP enable bit (SFCF[6]) must be enabled, otherwise, the FLASH programming command will not work. All IAP commands can only be executed in IAP mode, but when the selected memory area has been enabled with security lock, IAP commands cannot be executed. When the programming command writes new data to the memory block, it must be ensured that the memory block is in an erased state, that is, its value is 0xFF. If the memory block is not erased, apply the appropriate erase command to perform the erase operation. In particular, do not perform programming or erase operations in the memory area where the CPU is loading code, which will lead to unpredictable programming and may cause the programming data to be damaged.
3.1 Chip Erase
The chip erase command can erase all data in the FLAH memory. This command is only valid when EA is 0. The execution flow is shown in Figure 2.
3.2 Block Erase
The block erase command can erase all data in any block of the FLASH memory block (block 0 and block 1). The block selection can be achieved by setting the value of the SFAH register. When SFAH[7] is 0, block 0 is selected; when SFAH[7:4] is E, block 1 is selected. The block erase operation procedure is shown in Figure 3.
3.3 Sector Erase
The sector erase operation can erase all the information of the sector. The size of the sector is 128 bytes. The sector to be erased is determined by the SFAH and SFAL registers. The execution flow chart of the operation is shown in Figure 4.
3.4 Byte Programming
The byte programming command is used to program one byte of data. The programming address is determined by SFAH and SFAL. The programmed data is stored in the SFDT memory. The flow chart of byte programming is shown in Figure 5.
4 Solutions
After an in-depth analysis of the problems of superimposed characters lost and program runaway in the character superimposition system, it was found that the reason affecting the normal operation of the system was that the reset pin of the character superimposition chip was reset by the interference signal, resulting in the loss of video superimposition information; or the PC pointer of the interference microcontroller exceeded the scope of the application program, resulting in the inability of the program to run normally. In order to enhance the anti-interference ability of the video character superimposition system, the watchdog function can be used to make the microcontroller automatically return to normal when the program runs away. The implementation principle is that the watchdog timer generates an internal reset signal when the count reaches the set value, so that the microcontroller re-runs the user program to refresh the video superimposed character information regularly. Ensure that the superimposed character information can still be superimposed on the video in time after it is lost. The improved program flow is shown in Figure 6.
5 Conclusion
The solution proposed in this paper can successfully solve the problems of video overlay information loss and program runaway by making full use of the internal resources of the SST89E58RD2 microcontroller without changing the hardware, so as to enhance the anti-interference ability of the video character overlay system. The solution proposed in this paper has been successfully applied. This has very important practical value for using the internal resources of the microcontroller to enhance the anti-interference ability of the system.
Previous article:Clock synchronization technology between C8051F120 and RS422 information line
Next article:Design of 16×64LED dot matrix display screen based on single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Smart speakers ignite the "lazy economy" AWE2019 highlights
- Experience of using C28x Filter Library!
- GD32E231 simulates IIC driving STTS751
- Analysis of the differences between nRF24L01 wireless data transmission modules
- Looking to buy Freescale's 9S12HY64 development board
- Can the MY-R16 board automatically obtain an IP?
- I disassembled a device but couldn't find any information. Can you help me analyze the three electrodes?
- Finally got it done, the full character set of the digital tube defined by myself, everyone is welcome to use it
- This white paper explains how to leverage the power of 5G to empower your product design!
- Which of the two ways of making differential lines of equal length internally is better?