Several ISP programming methods for P89LPC932

Source: Internet
Author: User

 

Original article from: http://www.autooo.net/autooo/electronic/case/cpu-dsp/2007-10-28/33644_4.htmlauthor: Chen Kai Wu jinhong Yunbo Release Date: 06:44:03 Source: China Electronic Technology Group Corporation

 Reference:

The lpc900 flash single-chip microcomputer can be encapsulated from 8-pin to 28-pin to meet various application requirements with limited cost and PCB space and high performance and reliability, high speed (6 times higher than traditional MCS51 single-chip microcomputer), low power consumption (power consumption less than 1 μA in power-down mode), high stability, small encapsulation, multiple features (embedded with many popular functional modules. P89LPC932 is an important member of the family, it integrates 8 KB Flash program memory, 512b static data storage, 512b E2PROM, I2C bus, SPI bus, enhanced UART interface, analog comparator, watchdog, four interrupt priorities, dual dptr, and supports/programming and other functions.

1 Basic ISP programming method of P89LPC932

1.1 three programming methods of internal program memory

Three programming methods of 8 KB program memory integrated in P89LPC932 are: System Programming (ISP), program running (IAP), and program in parallel.

Generally, ISP programming relies on an external tool (except the conventional parallel programmer) to Program program memory directly integrated into the processor. There are many common external tools mentioned here, and different processor vendors may provide different solutions. For example, based on different programming interfaces, there are multiple methods such as JTAG, single line, serial port, and SPI port. Although the programming method is different, the principle is similar. It relies on external conditions to trigger the processor and disconnects it from the process of normal internal user application code that is executed normally, instead, execute the code (or the Execution Code provided externally by the processor) that controls the erased program memory and program programming at a fixed location in its program storage space ), then, a user-specified binary code file that can be run by an embedded processor compiled on a PC is programmed into the program memory of the embedded processor through a communication method with a PC computer. This programming method only requires regular hardware configurations (some Processors may need some simple hardware circuits called download lines), rather than special programmers (parallel programmers, so even if the processor chip has been welded to the circuit board, programming can be realized, which is the true meaning of ISP. P89LPC932 uses its own asynchronous serial port to implement ISP programming. It does not require a special download line or download device. The method for triggering the switch from the LPC932 to the ISP programming mode is described in detail below.

The IAP programming method is similar to the ISP programming method, but it is not triggered by external conditions, but when the processor normally executes the user-designed application code, call the curing routine that executes the erasure and programming functions directly. Like ISP programming, IAP programming only requires regular hardware configuration. The ISP programming of P89LPC932 is actually implemented by calling the IAP service subroutine of the chip. The IAP service subroutine is stored in ff00h ~ Ffffh address space does not occupy user program space.

Concurrent programming requires an external professional programming device. In other words, this programming environment is not the hardware environment for the user's end application. When using this programming method, users usually have to put the processor chip separately on the parallel programmer for programming (if the processor chip has been soldered to the circuit board, the processor chip must be removed from the circuit board first ). After the processor chip program is completed, it can be put back to the circuit board, and then powered on to the processor for running, in order to see the running results of the new code written by the user. This is the most traditional programming method (the classic AT89C51 mainly uses this method for programming), but it is cumbersome and cannot meet the actual needs of Remote Upgrade today, therefore, it has gradually been replaced by convenient online programming methods such as ISP and IAP.

In general, the ISP mode is the easiest to use because it allows the processor to program on the target circuit board that is soldered to the user without complex code design, this feature allows users to upgrade the software after producing hardware products. In general, adding calibration information data and installing the latest software version on site is a common upgrade operation. In addition, ISP programming is particularly suitable for the user's product development stage. Obviously, you can easily and quickly change your program code and immediately view the running results of the new Code. P89LPC932 uses the serial port as the main communication interface of the ISP programming mode, making this series of processors more convenient than those that rely on the communication interfaces such as JTAG and SPI as the ISP programming interface. Generally, asynchronous serial ports are configured in embedded systems. In this way, you do not need a special ISP programmer for system programming, JTAG, SPI, and other similar programming methods generally require dedicated interface adapters or download lines to work together, which may increase user investment and costs.

To implement ISP programming, the P89LPC932 chip relies on a segment preset at the factory, this code is stored at the high-end 512b address of Sector 7 in the P89LPC932 code space (the 8 KB program memory in P89LPC932 is organized into 8 sectors, each of which has 1 kb ). This Code provides an interface between the device's underlying operation code (such as erasure and programming) and serial communication. If you need to use the ISP programming mode, do not erase or overwrite the sector that contains the preset ISP code, that is, Sector 7 (1c00 ~ 1 fffh), because the erasure operation of P89LPC932 is based on the slice.

 

As shown in 1, the hardware connection implemented with P89LPC932 is very simple. It only needs to use the VDD voltage to execute erasure and programming algorithms without special high Programming Voltage. Therefore, only one piece of TTL and RS232 level conversion chip is needed outside the chip (Common chips include max202 and maxcompute of Maxim, other companies, such as Ti, sipex, and linear, have chip products with similar functions. The asynchronous serial port in P89LPC932 can be connected to the RS232 serial port on the user's PC. You can run a simple terminal simulation program on your personal computer to implement ISP programming. However, there is a simpler way to run a ready-made free program, such as flashmagic, to achieve this purpose, this program integrates all the ISP functions for the Philips lpc900 series processor. The ISP code in P89LPC932 can automatically detect the baud rate of the asynchronous serial port on the chip to communicate with the user's personal computer, and then download and program the code under the control of the user's personal computer. To sum up, the ISP programming mode of P89LPC932 does not require an external programmer, but requires a certain amount of external circuits (serial communication circuits), and the ISP resident code needs to be retained, you need to add the ISP boot initialization program (such as detection initialization) to your application code, and the 2nd-bit ISP encryption (ISP/erasure prohibited) cannot be set.

 

 

Figure 1 hardware connection in the ISP Mode

1.2 How to enter ISP Mode

The following four methods can be used to trigger P89LPC932 to enter the ISP mode: the ISP mode is triggered by the Detection Status bit (the default status when the new chip is initially powered on ); enable the ISP mode after the reset is triggered by detecting the stop Controller signal (the most practical and common method ); after detecting a specific pulse on the reset pin during power-on, it is triggered to enter the ISP mode (that is, the hardware is activated to enter the ISP mode). The ISP code is called directly to enter the ISP mode.

1.2.1 enable ISP mode through Detection Status bit

When P89LPC932 is reset, whether to enter the ISP mode is controlled by a status bit, which is saved in a reserved position in flash memory, however, this location is not in the program memory space that can be addressed by P89LPC932. In the descent edge of the reset signal, the processor checks the value of this status bit. If the value is 0, the processor starts to execute the command from the address 0000h, the user's application code is usually stored here. If the value of this status bit is not 0, the processor will execute the code from another fixed address. The high 8 bits of this address (16 bits) are specified by the Reset vector, the 8-bit low is fixed as 00 H. That is to say, the value of the bootstrap vector will be the high byte of the program counter (PC), and the low byte is 00 H. If you are using a new chip, the State bit value in the chip is set to 1 at the factory and pre-programmed to 1eh. Therefore, after the new chip is reset, the code will be executed directly from the 1e00h address. Because the code starting from 1e00h is the ISP preset by Philips for the chip. If you want to execute code from the 0000h address, the status bit value can be cleared through the parallel programmer. In fact, the status bit can be cleared through the functions of the ISP Code. If you write your own application code to the program memory of P89LPC932, the status bit can be cleared, after the chip is reset, the processor will directly execute the user code. In addition, the ISP code can also be used to modify the start vector value. You can modify its value, that is, after the chip is reset, the address of the code execution is modified (if the LPC932 is triggered to enter the ISP mode), and the startup Code Compiled by the user is put there, this design is usually used to execute some special functions. However, if the user modifies the value of the boot Vector so that it is no longer 1eh, the user will no longer be able to use the preset startup code at the factory of the LPC932. If the starting vector is modified and points to an address that does not include any startup code, you have to use a parallel programmer to program the chip to restore its starting vector value. Otherwise, you will no longer be able to use this ISP programming method.

1.2.2 enable the ISP mode after the chip reset is triggered by detecting the stop Controller Signal

It is detected through asynchronous serial port that the stop Controller signal triggers the chip reset and then enters ISP mode. This is the second way to enter ISP mode. The stop Controller signal is a low level with a frame length on the receiving foot of an asynchronous serial port. The length of a frame is related to the working mode of the asynchronous serial port. For example, in "Mode 1" of an asynchronous serial port, a frame is equivalent to a transmission time of 10 bits. Generally, when a stop Controller signal is sent, the receiving pin of the asynchronous serial port will continue to be equal to the low level of many frames. However, in the first frame, the stop Controller signal will be detected. Note: If a mechanical switch is used to lower the receiving pin of an asynchronous serial port to create a stop control signal, and the processor is configured to allow serial interruption, the receiving interrupt mark of the asynchronous serial port must be processed throughout the process. Otherwise, the processor enters an uncertain state.

This method requires that the user application code that resides in the P89LPC932 program memory must include the code that initializes the asynchronous serial port. In other words, the user must enable an asynchronous serial port. At the same time, the bits (ebrr) in the special function register auxr1 must be set to 1, to allow triggering of processor reset when a stop Controller signal is detected. In addition, the boot vector configuration byte must be 1 EH (using the preset ISP code in P89LPC932), the status word is 00 H (so that the user application code can be executed), and 1 e00h ~ Do not use or erase Flash program memory of 1fffh. After this configuration is complete, the processor will reset as long as the receiving pin of the asynchronous serial port detects the stop Controller signal. After the reset, The LPC932 will execute the command from the address specified by the starting vector.

There are two problems you should know when using this trigger method. First, some USB-to-RS232 converters cannot send signals, so they cannot trigger the reset of the processor and enter the mode by detecting the stop Controller signal; the second is that the stop control character signal does not appear in normal serial communication, so you can safely use this trigger method.

 

1.2.3 hardware activation enters ISP Mode

The advantage of using this mode is that no matter what user code is stored inside the processor, or what the status bit value is, the ISP mode can always enter (but one thing must be guaranteed, that is, the original processor is not erased or overwritten, and the default 1eh has not been modified ). Because P89LPC932 has a small number of pins and built-in program memory, there is no traditional P0, P2 port and psen pin for the extended bus, therefore, the method of triggering the chip to enter ISP mode is different from that of traditional MCS-51 chip.

After power-on, if the processor detects the pulse waveform 2 on the reset foot, the processor will run the command from the address specified by the boot vector, that is, entering the ISP mode, instead of executing the command from limit H. In fact, the result of this entry method has the same effect as a non-zero status byte. However, it should be noted that only three pulses can be generated, and more than or less than three pulses cannot trigger the processor to enter the ISP mode.

Figure 2 waveform of hardware-activated ISP Mode

An external microprocessor can be used to generate these three pulses, and it also controls a power chip to generate the power supply voltage required for P89LPC932. The principle of this method is easy to understand. I will not go into details here. In addition, a simpler method is to add some hardware circuits to the asynchronous serial port on the user's PC to directly generate the required sequence. For more information, see References 1.

 

1.2.4 direct call method trigger processor to execute ISP Code

The preset start vector of the ISP mode of P89LPC932 is 1eh, so the first address of the ISP resident code is 1e00h. To access the ISP, you can directly call the code at 1e00h. In the C code, the program can call the ISP resident code (that is, enter the ISP mode) through the function pointer ).

 

 1.3 Use flashmagic on P89LPC932

Flashmagic is a free software tool that can program ISP programs for many Philips processors, including P89LPC932. Flashmagic tries to connect to the selected device at startup, but an error is usually reported here because no processor is in ISP mode, or there are other settings that need to be changed. Select the correct serial port on the PC controlled by flashmagic, and set the target device to P89LPC932, as shown in 3. Then, the P89LPC932 enters the ISP mode (if it is a brand new processor, it is already in ISP mode ). If this is not a brand new processor (status bit is not 1), you must use hardware to activate the processor to enter ISP mode, or, the processor reset is triggered by detecting the stop Controller signal and enters the ISP mode.

Figure 3 startup screen of flashmagic

If the processor reset is triggered by detecting the stop Controller signal and enters ISP mode, as shown in figure 4, flashmagic should be configured to use this method to initialize ISP mode. First, check the "advanced options" option under the "options" menu, on the "Hardware config" page in the displayed dialog box, cancel the selection in the "use DTR and RTS to enter ISP mode" selection box (Note: flashmagic can remember your various settings, you can use it again next time. If you do not need other settings, you can use it without setting it again ). Select Start bootrom from the ISP menu, and select send break condition from the pop-up dialog box, flashmagic can directly send a stop control signal to P89LPC932 through a serial port of a PC. Generally, P89LPC932 should be in ISP mode. However, flashmagic does not automatically verify whether P89LPC932 has actually entered the ISP mode. You need to do this by yourself. If P89LPC932 is not in ISP mode, several flashmagic menus cannot be used (even if you select these menus, flashmagic will report an error without execution results ), you can select these menus to check whether P89LPC932 is in ISP mode, for example, "blank check…" under the "ISP" menu ..." . Of course, when P89LPC932 does not enter the ISP mode, it cannot be programmed. In this sense, we can also know that P89LPC932 is not in the ISP mode.

 

Figure 4 sending Conditions

The default setting of flashmagic is to automatically protect the startup code of the high-end 512 bytes in Sector 7 of P89LPC932. However, you can disable this protection function in the options-advanced options-security dialog box. However, we do not recommend that you do this because it increases the possibility of misoperations to overwrite the ISP startup code. Datasheet:

 

Note that some menu options may be different in the new flashmagic version. This article uses the 1.74 version of flashmagic. By the time of the deadline, flashmagic has been upgraded to version 2.07.

 

2. Conclusion

Philips P89LPC932 is a high-speed 51 compatible microprocessor with comprehensive functions, simple use, reliable performance, and high cost performance. It is suitable for product R & D, small batch product trials, scientific research in universities, and many other fields. This article describes the specific methods and techniques for P89LPC932 programming. It is hoped that readers will make full use of the excellent online programming features of P89LPC932.

 

References

1 Zhou ligong microcontroller Co., Ltd.. the ISP Application Design of P89LPC932, 2004

2 Philips co. application note. insystem programming (ISP) with the Philips P89LPC932 microcontroller, 2003

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.