introduction
This system is designed to address the problem of serious overdraft of groundwater resources and serious damage to water resources. The purpose is to monitor the water use of agricultural wells. Agricultural wells are widely distributed in sites, with distances between sites ranging from tens of meters to one or two hundred kilometers. Manual meter reading and monitoring will waste a lot of manpower and material resources, and the real-time performance is poor. The GSM method used in the past also had problems of poor real-time performance and difficult control.
At present, a reliable and realistic solution to such problems is to connect on-site equipment to a server on the Internet to achieve real-time monitoring and management at the upper level; however, there are no dedicated Internet access points and equipment on site. Using GPRS to access the Internet for remote data transmission has been a hot topic in enterprises, research institutes and other scientific research institutions in the past two years. With the increasing maturity of GPRS technology, GPRS has been successfully used in remote data transmission systems such as remote meter reading, night light lighting, oil field monitoring, automatic measurement, smart instruments, etc. that are inconvenient or even impossible to operate manually. Therefore, this system uses a hybrid working mode of GPRS and GSM: GPRS working mode is used when the network condition is smooth; otherwise, it can be switched to GSM working mode. Each site data transmission terminal logs in to GPRS regularly, accesses the host server on the Internet, and downloads the collected data and site status to the server hard disk; the upper layer uses B/S browser mode to provide different services at the prefecture level, district level, city level, etc. Level setting permissions for browsing; at the same time, you can monitor the real-time status of the site at any time, report real-time on-site conditions, and call system historical data information.
Market opportunities and the maturity of application technology are often a contradiction. Especially for new technologies such as GPRS, we usually have to develop the market and improve the technology at the same time. However, practice is the only criterion for testing truth. After the system is handed over and used, users will give feedback on how to improve the functions. In addition, after long-term use, hidden "bugs" in the terminal program may also surface. This requires upgrading the program of the data transmission terminal, but imagine that if 200 sites are put into use, even if ISP on-site online programming is used, the staff will have to update the program at each site. It not only wastes a lot of manpower and material resources, but also directly delays the opportunity to open up the market, and the consequences for the enterprise may be fatal.
This design solution is applied to this type of GPRS remote monitoring system and integrates GPRS network communication technology to solve the problem of data transmission terminal program upgrade.
1 Introduction to IAP functions and system applications
IAP (In? Application Programming) is a programming mode applied to Flash program memory. Simply put, it is to read, erase, and write a certain section of the program's storage space under the control of the application program. It is very similar to the ISP (In? System? Programming) operation. There is no need to remove the chip from the circuit board, program it with a programmer, and then install it to run a new program, that is, it has an online programming function. But they have their differences: ISP usually erases and programs the entire chip, and downloads the program to Flash through the PC serial port under manual operation, which requires simple hardware resources-serial port RX, TX and RS232 driver chips; while IAP Under the control of a certain program, the read and write operations of another program Flash can be controlled to read and write operations on a certain segment, a certain page or even a certain byte.
According to the functional characteristics of IAP, simulation software can be made to replace the emulator function. By making a simple interface application on a PC, you can directly realize online simulation of user programs: setting breakpoints, single-step running, changing running results, debugging and other functions. In the same way, the programmer can be replaced according to the functional characteristics of the ISP. This system integrates the IAP mode into the GPRS communication system and uses GPRS to remotely upgrade the software of the designated target chip.
2 IAP functional system architecture
The IAP functional system architecture is shown in Figure 1.
P89LPC936 is a high-stability, multi-functional 51-core MCU launched by Philips; it integrates the I2C bus, and the I2C device FM24C256 has fast read and write operation speed and high stability; enhanced UART, with frame error detection, frame interval detection, Optional double buffering, optional separation of receive and send interrupts and other powerful serial communication functions enhance the reliability of serial communication with the GPRS module; built-in AD/DA converter; 16 KB Flash accessor, supports ISP and IAP; adopts TSSOP28 or HWQFN28 low-cost package. The peripheral circuits of the designed system can be reduced to a minimum, which not only improves the performance of the system, but also allows IAP to upgrade some terminal functions without changing the peripheral hardware circuits.
FM24C256, 256 Kb FRAM (ferroelectric memory), has the power-down data storage characteristics of ROM and the read and write speed and number of times of RAM. The number of read and write times reaches 100 billion times. It uses I2C bus read and write operations, making it stable and reliable in use; 8-pin SOIC package, the interface circuit with MCU is simple and the communication is reliable. Communication rate is adjustable from 0 to 400 kHz. The values of the two SFRs I2SCLH and I2SCLL of P89LPC936 determine the duty cycle of the serial clock generator. This system chooses 7.372 8 MHz crystal oscillator, I2SCLH=I2SCLL=75, and the I2C rate is 25 Kbps.
The GPRS module uses Q2406B produced by WAVECOM, a dual-frequency GPRS/GSM module (EGSM900/1 800 MHz or EGSM900/1 900 MHz), with built-in TCP/IP, fully compatible with standard AT commands; its design and development comply with ETSI GSM Phase 2+ standard. This system module uses a baud rate of 9.6 kbps, while the factory baud rate of the module is 115 200 bps. Pay special attention to this when initializing the module with a serial terminal.
3 Software programming of IAP function
3.1 System working status analysis
① User program working status. In the remote data transmission system, the user program completes data collection, storage, sending, system monitoring, alarming, and receives and executes normal user functions such as host computer settings and control commands.
② IAP working status, as shown in Figure 2. The host computer sends the upgrade program signaling. After the data transmission terminal receives and replies the confirmation message, it starts waiting for the download signaling; after receiving the correct download signaling, it starts downloading the code to FM24C256 for temporary storage. Send and receive data according to the frame sequence number, verify the correctness of the frame, and use handshake data flow to ensure that each frame is received and stored correctly. After the code is sent, the download completion signaling is sent, including the total length of the code and the block check code; delay processing is adopted at each stage: the delay time is up and the resending process continues three times. If it is not received, an error message is reported and the system is forced to go offline. , switch to run the user program to be upgraded. If the communication is normal, enter the most critical step - Flash erasure and programming.
Philips solidifies a 256-byte boot ROM in the space of P89LPC936 address FF00H~FFFFH. All MCU operations on the internal Flash can call this subroutine to complete. When using the IAP function, you provide the entry parameters of this subroutine (refer to the Philips data manual), and then call the entry address FF00H of the program to realize reading, writing, and erasing the Flash. When erasing and programming Flash, all interrupts need to be turned off. The same Flash cannot be erased and programmed at the same time, and the sectors must be cleared before programming. The program list for erasing Flash sectors (entry parameters A, R7, R4 and R5, return parameters (F0 (C), R7)) is as follows:
ERASE_FLASH:
MOVA, #04H; A is the operation type (A=04H, tells IAP; the erase operation is performed)
MOVR7, #01H; R7 delete operation mode (00H means delete; page; 01H means delete sector)
MOVR4, #HIGH; The upper 8 bits of the Flash address to be operated
MOVR5, #LOW; The lower 8 bits of the operating Flash address
LCALLFF00H
JCERASE_FLASH; F0 (C): 0 means erasure is successful, 1 means
; Erase failed
3.2IAP function system SFR configuration
(1) User confidential sector setting MOVSEC6, #04H; prohibits erasing of Flash sector 6. MOVSEC7, #04H; prohibits erasing of Flash sector 7. The codes for sectors 6 and 7 are to control erasure and programming. Flash. To ensure against misuse, it is only allowed to be erased and written using a special programmer before leaving the factory.
(2) IAP privileged key value setting To execute the IAP function of erasing or writing Flash, you need to write 96H into the RAM unit FFH to set the privileged key value before calling the IAP function program. The program code is as follows: MOVR0, #0FFHMOV@R0, #96HIAP After the program completes the function call, the privileged key value is cleared. Therefore, the privilege key value must be set before each call to the IAP function program.
3.3IAP function implementation process
The IAP function implementation process is shown in Figure 3 and Figure 4. flagIAP is a sign that the download program is completed and the check code is confirmed, and the Flash is ready to be erased. It is very important to open up the unit storage function in FM24C256: when an abnormality occurs in program erasing, such as power-off reset, you can continue to complete the upgrade task after the program is started and the erasing is confirmed with the host computer. The number of bytes programmed each time is consistent with the number of code bytes in one frame of data transmitted by the host computer. The frame number indicates how many frames of transmission and how many programming operations the program is divided into.
Previous article:Design of audio signal amplitude equalization control amplification circuit based on AT89C51 microcontroller and amplifier
Next article:Design of intelligent solar street light control system using LPC935 microcontroller as main controller
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
- stm32f030R8 Chinese reference material
- Recruitment: Executive Vice President of Automotive Electronics (Executive Vice President of New Energy)
- ATmega4809 Curiosity Nano Review + Unboxing and Powering on
- Sell an unused Jiuxintaike oscilloscope and get a Guwei desktop multimeter for free
- MSP430F1232 external 4M crystal oscillator cannot start
- Q: How do you determine the inductance value when selecting a common-mode coil?
- What does BMS device learning and chemical ID mean?
- [NUCLEO-L452RE Review] + Simple Digital Voltmeter
- Gaoyun FPGA various manuals
- [2022 Digi-Key Innovation Design Competition] ESP32S2 Lighting