In the system programming technology (In-System Programming, is called the ISP technology) is one kind which the Lattice semiconductor company first proposed causes the product in the design, process of manufacture each link, even after selling to the end-user, has to its component, the circuit wafer either the entire electronic system’s logic and the function momentarily carries on the configuration or the reorganization ability newest technology. The ISP technology eliminated traditional technology certain limits and connection disease, is advantageous in the board design, the manufacture and the programming. ISP hardware nimble and easy software fix, is advantageous for the design development. Because the ISP component may look like any other components to be the same, processes on printed wiring board PCB, therefore programs the ISP component not to need the special programmer and the complex flow. In the practical application, many products need the mass the production and on-site maintenance promote, may facilitate the user using the bedded system development’s ISP application procedure to carry on the volume production and the system upgrade. This article take carries on the software to Phlilips LPC213x series MCU to promote as the example, how studies unifies using the ISP technology and Internet, solves carries on the question which from the serial port the software promotes.
1 LPC213x Flash Bootloader introduction
After LPC213x Bootloader (start loading operation) controls the replacement the initialization operation, and provides Flash the ISP programming connection. It is resident in Flash on 8KB, can only read cannot write. How because Philips Corporation hasn’t provided Boot the ROM interior is realizes the ISP function, must therefore provide according to Philips Corporation the flow and the agreement compile the superior machine procedure.
1.1 communication protocols
All ISP order by superior machine through serial port by single ASCII string of character form transmission. The string of character must and/or line feeds the (LF) control character by carriage return (CR) to take the conclusion, unnecessary will be neglected. All ISP response by “<CR><LF>” conclusion string of character form transmission. The data by the UU code (the ASCII character repertoire which may print 3 byte binary system data conversion 4 bytes) form transmission and receive. After the transmitter transmits 20 UU code line, sends the verification and, any UU code line of length should not surpass 61 bytes. The receiver and compares this verification and with the receive data’s verification, if matches, then the receiver responds “0K<CR><LF>”, and waiting next transmission; If does not match, then the receiver responds “RESEND<CR><LF>”, the transmitter must transmit the byte.
1.2 ISP orders
The ISP command processor accepts commonly used order like table 1 arranges in order.

Each order has the concrete state code, only then, when receives after the order execution finished, the disposal procedure only then transmitted CMD_SUCCESS through the serial port; By now the superior machine could transmit the new ISP order, but “the establishment baudrate”, “writes RAM”, “to read the memory” and “the movement” the order exception. The superior machine is transmits these related ISP order as well as the procedure UU code through the serial port, completes the procedure downloading.
2 superior machine softwares realize
2.1 application procedure on-line downloading
Must realize the software to promote automatically, must first the MCU application procedure from-line downloading to PC machine, then download again using ISP through the serial port the procedure to MCU. Procedure downloading may select the HTTP method, may also select the FTP method. In this is the use: MFC provides the FTP application program interface realizes procedure downloading, and is assigning the procedure preservation the position. In order to avoid when each time promotes the procedure, must from-line downloading, introduce the counter computation downloading number of times; Only when the ~th promotion, only then from-line downloading preservation.
2.2 ISP realizations
LPC213x must transfer in Boot ROM the ISP application program interface, must enter the ISP pattern. This request when system reset, the PO.14 pin is the low level. In the practical application may use two methods to cause the system to enter the ISP pattern: First, through the stop-go control P0.14 pin is the low level; Second, controls transistor’s breakover and the closure through the serial port control pin, thus establishes PO.14 is the low level. The second method has the versatility, some MCU enters the ISP pattern request is possibly the pin different pulse train, namely must satisfy certain pulse succession request (for example MSP430 series MCU). Uses what in this is the second method: Connects P0.14 the serial port DTR pin, the serial port RTS pin connects LPC213x the replacement pin; Through when systems operation controls the RTS pin to send out the reset pulse, the DTR pin establishes as the low level, controls transistor’s breakover and the closure, causes the system to force to enter the ISP pattern; After entering the ISP pattern, transmits the ISP order according to the superior machine, transfers Boot in the ROM firmware the corresponding subroutine to complete the essential operation automatically. Chart l described LPC2132 to enter the ISP pattern from the replacement the flow.

The concrete superior confidential realizes this procedure downloading, must complete the following work:
①Form’s application procedure will open from-line downloading Intel the HEX, analyzes the program file which from the document must download, and transforms it into the binary form.
②To lower position machine transmission synchronization confirmation character “?”(0×3F), for the automatic determination baudrate, and waits for the response. The automatic baudrate procedure acts according to the synchronized character position time which own frequency measurement receives, and carries on the programming to the serial port baudrate generator; It also to lower position machine transmission ASCII string of character (Synchro-nized<CR><LF>). As the response, the lower position machine should transmit ASCII which receives string of character (Synchrtmized<CR><LF>); The superior machine the character which receives through the observation confirms whether synchronization. If the synchronized confirmation has not passed, then superior engine weight new transmission synchronization confirmation character “?”, carries on the synchronized confirmation again. After confirmation, to lower position machine transmission “OK<CR><LF>”; The lower position machine is moving the part crystal oscillator frequency through the transmission (unit is kHz) takes the response; After receiving the crystal oscillator frequency to the lower position machine transmission “OK<CR><LF>”, completes the synchronized confirmation finally again.
③Reads the component ID order to the lower position machine transmission “J<CR><LF>”, the receive response message, and withdraws the chip the ID serial number; According to chip ID, establishment correlation data (Flash and RAM size).
④To lower position machine transmission erase command Flash ROM partition cleaning.
⑤Writes the order to the lower position machine transmission “W< start address >< byte count ><CR><LF>”.
⑥After transforming the binary procedure carries on the UU code, and calculates the verification and, transmits 20 lines to transmit a verification sum every time; Then the downward position machine transmission prepares wrote the operation sector the order “P< outset sector >< conclusion sector ><CR><LF>” and “C<Flash address ><RAM address ><CR><LF>” the order, after the lower position machine receive order, to carry on the procedure read-.
⑦Closure serial port, release system resources, with the aim of carrying on the next subsystem promotion.
Conclusion
Arab League winds the online downloading system through this design constitution, already obtained the practical application in the Renminbi forgery-proof detector’s production and the post-sale maintenance. Only needs the computer which and a downloading line can access the net, can monolithic integrated circuit’s procedure make the revision to the goal board, has facilitated the engineers and technicians greatly, raised the working efficiency, reduced the cost.