Three Programming Methods for Microcontrollers: ISP, IAP, ICP

Three Programming Methods for Microcontrollers: ISP, IAP, ICP

IAP

Let’s start with the most relevant topic mentioned above, IAP (In Application Programming). As the name suggests, it means that user code can erase and program the flash memory area. Different MCUs have different flash memory addresses; for example, the flash memory starting address for LPC1778 is 0x0, while for STM32 it is usually 0x0800 0000.

IAP is typically used by developers for remote upgrades. A typical application is to have two code areas: the first area checks on each power-up whether the second program needs to be updated, and the second area contains the actual functional code.

Method Dependencies

MCU supports IAP;

Program design supports IAP;

No other tool dependencies;

ISP

ISP (In System Programming) usually runs the manufacturer’s bootloader to enter ISP mode or support ISP protocol communication. When in ISP mode, users can erase or program the flash memory (which is just a regular storage space at this time) via software (such as flashMagic or ISP programmer). Different chip manufacturers may also provide their own ISP programming tools.

Methods to Enter ISP Mode

The specific method varies for different MCUs. For example, NXP leaves a dedicated ISP port, indicating that when this pin is grounded, ISP communication can be done via serial port; the ST series uses BOOT0 and BOOT1 to select where to start the program, specifying the available serial pins.

Three Programming Methods for Microcontrollers: ISP, IAP, ICP

Figure 1: LPC17x ISP Function Description

Three Programming Methods for Microcontrollers: ISP, IAP, ICP

Figure 2: STM32 Program Startup Mode Selection

Method Dependencies

  • Programming tools or serial port assistants on the host;

  • Communication interfaces used for programming, usually but not limited to UART;

ISP vs IAP

The essential difference between ISP and IAP is that one is programming flash memory through the manufacturer’s bootloader, while the other is through a bootloader developed by engineers like us.

2. ISP uses boot programs to program via USB/UART and other interfaces, which requires a BootLoad program. The most common programming method is the STC-ISP programming tool used when learning about the 8051 microcontroller.

ISP does not have a universally applicable protocol. More importantly, this method varies for each MCU, with implementations and supported operations not being completely the same, having a certain level of proprietary nature; it also requires certain host and communication hardware interfaces to achieve flash programming.

3. IAP is a method that achieves online erasure and programming through software without using any tools, merely updating data in Flash through software methods.

For example, a case can be described where a 4G module is used to remotely update the program. The Flash is divided into two areas: the first area is the BootLoad program, and the second area stores the application program (APP). The 4G module communicates with the target board, including a bit indicating whether an update is needed. If the mainboard receives the update bit, it writes a flag, such as ‘P’, into Flash. Then the program jumps to the first BootLoad program, checks if there is an update flag ‘P’ in Flash, and if so, it updates the application program according to the specified protocol. After the update, it clears the update flag in Flash and jumps to the application program for execution. If there is no update flag ‘P’, it jumps directly to execute the application program.

IAP does not require external tools; flash programming can be performed directly through APP area 1 (programming APP area 2).

ICP

ICP (In Chip Programming) mainly refers to the firmware burning of the flash area through the developer’s IDE or J-Flash, usually requiring SWJ support.

1.ICP uses the SWD interface for programming. Common programming tools include J-Link, ST-Link, and Nu-Link. The accompanying programming software includes J-Flash, NuMicro_ICP_Programming_Tool, and ST-Link utility.

Method Dependencies

  • Host computer;

  • Debugger;

  • ICP: Uses SWD interface for programming, such as J-Link programmer and J-Flash software.

  • ISP: Uses boot programs (Bootload) along with peripheral UART/USB interfaces for programming.

  • IAP: Software achieves online erasure and programming without using any tools. The program is usually divided into two parts: the boot program and the application program.

Leave a Comment