Design of remote IAP function system based on P89LPC936 microcontroller and Q2406B module

Publisher:脑洞飞扬Latest update time:2023-04-07 Source: elecfansKeywords:P89LPC936 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

[1] [2]
Keywords:P89LPC936 Reference address:Design of remote IAP function system based on P89LPC936 microcontroller and Q2406B module

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

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号