There are two major types of programming of internal flash memory in microcontrollers, as follows.
- Programming of device on target system
These two programming methods differ only in the state of the target device; the basic programming method is the same.
Other than that, some devices support self-programming, but this will not be covered here.
In the case of programming of a stand-alone chip, in addition to the programmer, a socket adapter for setting the target device is also required.
Normally, it is simpler to use the adapter (FA Series) manufactured by Naito Densei Machida Mfg. Co., Ltd.) for this.
During device programming on the target system (called on-board programming), signals are simply exchanged between the powered target system and the programmer.
2. Required equipment
The following equipment is required for programming.
- Parameter file (Downloaded from NEC Electronics homepage)
- PC for control
- FA adapter with the required wiring (in the case of stand-alone programming)
(target system in the case of on-board programming)
3. Device/programmer interface
To perform programming, signals are exchanged between the device and the programmer.
Basically, three types of signals are employed:
- Serial signals
- Operating clock (when required)
Among the power supply/control-related signals, VPP, in addition to being used as a power supply for programming, is also used to specify the mode to be used for serial communication between the device and programmer.
Moreover, VDD, during programming of a stand-alone chip, can be supplied from the programmer, but in the case of on-board programming, it does not have the capacity to drive the entire board, so a separate power supply is required.
For the serial signal, select a signal according to the communication mode that is actually used.
Use one of the available serial ports for on-board programming.
(Since the communication mode differs according to the target device, please select the communication mode according to each device.)
The programming time can be shortened the most using 3-wire serial communication with handshake.
However, this mode is not supported by the FL-PR2.
The operating clock can be supplied from the programmer if no clock generation function is provided on the device side in stand-alone programming.
However, the frequency is somewhat restricted in this case.
In the case of on-board programming, the clock is basically generated by the target system, and does not need to be supplied from the programmer.
4. Basic exchanges between the device and programmer (Initialization)
When performing programming, the programmer first supplies VDD to the device.
After the lapse of the rise time of the power supply, VPP is supplied, and after waiting for the rise time, RESET is released.
Then the system waits for the clock oscillation stabilization time.
The device goes into the flash programming mode through RESET release and clock supply (oscillation).
Then, the programmer notifies the device about the type of interface used for communication by converting VPP into a pulse.
Since this processing must be performed within a given interval of time, make sure that no circuit that greatly prolongs the time until device RESET is actually released after the programmer releases RESET is inserted.
After completing the interface condition settings, the programmer sends the initialize command to the device a maximum of 16 times, using a serial signal.
If the ACK signal is returned from the device within these 16 times, the device is ready to communicate.
(If there is an error in the processing up to this point, the error message "Target initialize error" is displayed.)
5. Programming and verifying Normally, the EPV command is used during programming, but in this case, V (Verify) processing is performed within the device and verify of individual data is not performed.
To more accurately check the write data itself, execute the verify command by itself after programming.
The flash programming data cannot be read out externally, for program protection purposes.
Moreover, from the same viewpoint, verify cannot be executed by specifying an address.
6. Parameter file
A parameter file is provided for each individual device.
Moreover, the parameter file may also differ depending on the device version, the clock that is used, or the interface conditions, so use the parameter file that matches the device to be programmed.