Page 1
On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
Page 2
Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
Page 3
User’s Manual μ PD78F0711, 78F0712, 78F0714 8-Bit Single-Chip Microcontroller Flash Memory Self Programming μ PD78F0711 μ PD78F0712 μ PD78F0714 Document No. U18886EJ1V0UM00 (1st edition) Date Published September 2007 NS 2007 Printed in Japan...
Page 5
NOTES FOR CMOS DEVICES VOLTAGE APPLICATION WAVEFORM AT INPUT PIN Waveform distortion due to input noise or a reflected wave may cause malfunction. If the input of the CMOS device stays in the area between V (MAX) and V (MIN) due to noise, etc., the device may malfunction.
Page 6
EEPROM is a trademark of NEC Electronics Corporation. • The information in this document is current as of September, 2007. The information is subject to change without notice. For actual design-in, refer to the latest publications of NEC Electronics data sheets or data books, etc., for the most up-to-date specifications of NEC Electronics products.
Page 7
INTRODUCTION Readers This User’s Manual is intended for users who wish to understand the self- μ programming function of the PD78F0711, 78F0712, and 78F0714 and design application systems using these microcontrollers. Purpose This User’s Manual is intended to give users an understanding of the creation of μ...
Page 8
Terminology The following describes the meanings of certain terms used in this manual. • Self programming Self programming operations are flash memory write operations that are performed by user programs. • Flash memory control firmware This firmware provides an interface for flash memory manipulations performed by μ...
CHAPTER 1 OVERVIEW OF FLASH MEMORY SELF PROGRAMMING μ PD78F0711, 78F0712, and 78F0714 supports flash memory control firmware that is used to rewrite flash memory. This firmware control enables flash memory to be rewritten from application programs. Possible uses of self-programming include the following. •...
CHAPTER 1 OVERVIEW OF FLASH MEMORY SELF PROGRAMMING 1.2 Control of Flash Memory Control Firmware The user performs flash memory write or erase via the flash memory control firmware. The self-programming operation contents are indicated to the firmware from the user's application program, and the firmware performs flash memory write or erase.
CHAPTER 1 OVERVIEW OF FLASH MEMORY SELF PROGRAMMING 1.3 Self Programming Modes The self programming mode is determined by the FLSPM values (values of bits 1 and 0 of FLPMC register). <1> Normal mode This is the mode for executing user applications. After reset release, the operation starts in this normal mode.
CHAPTER 1 OVERVIEW OF FLASH MEMORY SELF PROGRAMMING 1.4 Hardware Environment The voltage of the FLMD0 pin must be set to low level during normal operation and to high level during self programming. Figure 1-2 shows an example of a circuit that switches the voltage of the FLMD0 pin through port manipulation.
CHAPTER 1 OVERVIEW OF FLASH MEMORY SELF PROGRAMMING 1.5 Software Environment When performing self programming, the resources shown in Table 1-3 and Figure 1-3 below are required. For details, refer to 2.6 Parameters for Controlling Flash Memory Control Firmware. Table 1-3. Software Resources Item Description Register bank...
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.1 Registers That Control Self Programming 2.1.1 Flash programming mode control register (FLPMC) This register is used to enable/disable flash memory access (write, erase, etc.), and indicate the self programming operation mode. A particular sequence must be used when writing to this register, in order to prevent inadvertent settings due to noise or manipulation errors.
Page 16
CHAPTER 2 SELF PROGRAMMING FUNCTIONS [FLSPM0 and FLSPM1] These control flags are used to select the self programming operation mode. FLSPM1 FLSPM0 Mode Selection Normal mode • Access (instruction fetch, data read) to the entire address range of flash memory is possible. Self programming mode •...
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.1.2 Flash protect command register (PFCMD) To prevent erroneous flash memory write or erase caused by an inadvertent program loop, etc., protection is implemented by this register for flash programming mode control register (FLPMC) write. The FLPMC register is a special register that is valid for write operations only when the write operations are performed via following special sequence.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.1.3 Flash status register (PFS) If the flash programming mode control register (FLPMC) is not written in the correct sequence, the FLPMC register is not set and a protection error occurs. At this time, bit 0 (FPRERR) of the PFS register is set to 1. This flag is a cumulative flag.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.2 FLMD0 Pin Manipulations For self programming, the level of the FLMD0 pin must be changed. The firmware execution requires that FWEDIS = 0, in addition to high level input to the FLMD0 pin. Table 2-1. Levels of FLMD0 Pin Based on Flash Programming Mode Normal Mode Self-Programming Mode Pin Name...
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.3 Self Programming Mode and FLMD0 Pin Control Figure 2-3 shows the actual voltage change timing for each register and the FLMD0 pin. Figure 2-3. Self Programming Mode and FLMD0 Signal Timing FLMD0 pin becomes low FLMD0 pin becomes high level in self programming mode level in self programming mode...
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.4 Functions of Flash Memory Control Firmware Table 2-2 lists the flash memory control firmware functions (commands). To use these functions, specify the function numbers in self programming mode. For details about the functions, refer to CHAPTER 3 ACCESS TO FLASH MEMORY. Table 2-2.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.5 Flash Memory Control Firmware Use Environment Table 2-3 lists the conditions required for operation of the flash memory control firmware. Table 2-3. Conditions for Firmware Operation Item Description Secure entry RAM area During firmware operation, bytes required...
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.6 Parameters for Controlling Flash Memory Control Firmware As was mentioned above, access to flash memory (for erasing or writing) is performed by the firmware. The operation instructions are sent from the user application to the firmware via parameters in RAM. There are the following three types of control parameters.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.6.1 Register bank 3 When executing the flash memory control firmware, set the firmware’s function numbers to C register of register bank 3, and the start address of the entry RAM to HL register. The firmware execution results can be checked with B register. Table 2-4.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.6.2 Entry RAM The entry RAM is a 48-byte area used to set the firmware functions. The setting contents vary according to the firmware function. The entry RAM can be placed to any addresses in the internal high-speed RAM, and the start address of the entry RAM is set with HL register of register bank 3.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.6.3 Data buffer The data buffer is an area used to pass and receive data to be written to the flash memory and set information, and its contents vary according to the firmware function. The data buffer can be placed to any address in the internal high-speed RAM, and its start address is specified in the entry RAM.
CHAPTER 2 SELF PROGRAMMING FUNCTIONS 2.6.4 Flash memory block numbers The areas used to perform blank check, erase, and verify are specified in block (2 KB) units. μ The boot swap ( PD78F0714 only) is performed in cluster (4 KB) units. Caution Areas (banks) other than the on-chip flash memory of the product cannot be accessed.
CHAPTER 3 ACCESS TO FLASH MEMORY This chapter describes flash memory access methods. 3.1 Overall Flow The following describes the overall flow of flash memory manipulations by the entry program. At each stage in this flow of manipulations, the flash memory control firmware is called only when all of the hardware and software use conditions have been met and all of the required parameters have been set.
Page 30
CHAPTER 3 ACCESS TO FLASH MEMORY Figure 3-2 outlines the programming part for self-flash. Before performing flash memory write/erase, perform [Initial settings] → [Initialization] → [Mode check], in this order. Then execute the required functions the required number of times. Figure 3-2.
CHAPTER 3 ACCESS TO FLASH MEMORY 3.2 Initial Settings Check the usage conditions and enable self programming. <1> All interrupts are masked (interrupts are masked by the interrupt mask flag or executed by the DI instruction). <2> TM50 is not being used (TM50 will be used by the firmware). <3>...
Page 32
CHAPTER 3 ACCESS TO FLASH MEMORY (4) Register memory state following firmware execution • Start address (HL register) of entry RAM held (5) Stack size • 26 bytes (6) Other • Frequency data: The frequency data (Hz) is set to the data buffer as a 4-digit hexadecimal value. Table 3-1.
Page 33
CHAPTER 3 ACCESS TO FLASH MEMORY (7) Flowchart example Figure 3-3. Initialization Flowchart Initialization • Set C register to 00H Parameter settings • Set HL register to start address of entry RAM • Set data buffer start address in entry RAM (+08H, +09H) CALL #8100H •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.4 Mode Check (1) Function • Check level (high or low) of FLMD0 pin Caution If FLMD0 pin is at low level, flash memory cannot be erased or programmed. Therefore, when writing to flash memory with self programming, execute this subroutine after initialization.
Page 35
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart example Figure 3-4. Mode Check Flowchart Mode check • Set C register to 0EH Parameter settings • Set HL register to entry RAM start address (can be omitted if settings are not changed) CALL #8100H FLMD0 pin level judgment Error processing...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.5 Block Blank Check (1) Function • Performs a blank check of a specified block. (2) Arguments Item Description Function no. Set C register to 08H. Start address of entry RAM Set any address in internal high-speed RAM to HL register. Blank check block Set block number to be blank-checked to entry RAM (+07H).
Page 37
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-5. Block Blank Check Flowchart Blank check • Set C register to 08H Parameter settings • Set HL register to entry RAM start address (can be omitted if settings are not changed) •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.6 Block Erasure (1) Functions • Erases a specified block. (2) Arguments Item Description Function no. Set C register = 03H. Start address of entry RAM Set any address in internal high-speed RAM to HL register. Erase block Set block number to be erased to entry RAM (+07H).
Page 39
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-6. Block Erasure Flowchart Erase • Set C register to 03H Parameter settings • Set HL register to start address of entry RAM (can be omitted if settings are not changed) •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.7 Word Write (1) Function • Writes data to the flash memory. • Used to write programs. (2) Arguments Item Description Function no. Set C register to 04H. Start address of entry RAM Set any address in internal high-speed RAM to HL register. Start address of data buffer Set any address in internal high-speed RAM to entry RAM (+08H, +09H).
Page 41
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-7. Word Write Flowchart Write • Set C register to 04H • Set HL register to start address of entry RAM (can be omitted if settings are not Parameter settings changed) •...
Page 42
CHAPTER 3 ACCESS TO FLASH MEMORY (7) Call example ; 04H → C register Selects word write function MOV C,#04H ; 0FC00H → HL register Sets start address of entry RAM to 0FC00H MOVW HL,#0FC00H ; 0FD00H → AX register MOVW AX,#0FD00H ;...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.8 Block Verify (1) Function • Performs internal verification of the specified block Note • After a write operation, be sure to perform internal verification of blocks that include the write range. Note Internal verification is a function that checks to confirm that the data written to flash memory was written at an adequate level.
Page 44
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-9. Block Verification Flowchart Internal verify • Set C register to 06H Parameter settings • Set HL register to entry RAM start address (can be omitted if settings are not changed) •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.9 Get Information The firmware’s flash information read function is used to read product information. The read information is then checked to see if it poses any problems for subsequent flash memory manipulations. (1) Function •...
Page 46
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Get information for option value The information selected with an option value is stored in the data buffer. <1> Security flag information (Option value: 03H): Note Obtain the onboard write/erase disable/enable status via the 1 byte of data from the beginning of the data buffer.
Page 47
CHAPTER 3 ACCESS TO FLASH MEMORY <3> End address of specified block (option value: 05H) Get end address of specified block with 3 bytes of data from start of data buffer. Table 3-4. End Address Data Format Offset Description Block end address, lower address Block end address, higher address Block end address, highest address Example: Block 0 (when end address is 0007FFH)
Page 48
CHAPTER 3 ACCESS TO FLASH MEMORY (8) Call example ; 09H → C register Selects get information function MOV C,#09H ; 0FC00H → HL register Sets start address of entry RAM to 0FC00H MOVW HL,#0FC00H ; 0FD00H → AX register MOVW AX,#0FD00H ;...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.10 Set Information (1) Function • Sets the boot flag. As a result, boot area swap is possible (boot swap function Note μ Note The boot swap function is supported only with the PD78F0714. (2) Arguments Item Description...
Page 50
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-11. Set Information Flowchart Information setting Set security flag boot flag • Set C register to 0AH • Set HL register to start address of entry RAM (can be omitted if not changed) •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.11 EEPROM Write (1) Function • Writes data to the flash memory during EEPROM emulation. • Used to write data. μ Remark For the data hold period and rewrite count, refer to the PD78F0711, 78F0712 User’s Manual μ...
Page 52
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-12. EEPROM Write Flowchart Write • Set C register to 17H • Set HL register to start address of entry RAM (can be omitted if settings are not Parameter settings changed) •...
Page 53
CHAPTER 3 ACCESS TO FLASH MEMORY Figure 3-13. Memory Map Size specified in entry FFFFH RAM (+07H) Address specified in entry Data buffer (RAM) RAM (+08H, +09H) Address specified in entry Write destination (flash memory) RAM (+01H, +02H, +03H) 0000H Size specified in entry RAM (+07H) (7) Call example...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.12 EEPROM Erase (1) Functions • During EEPROM emulation, the memory in a specified block is deleted only by the duration of given time (10 ms units). With this function, the deletion of one block can be divided into a number of short erasure processings.
Page 55
CHAPTER 3 ACCESS TO FLASH MEMORY (6) Flowchart Figure 3-14. EEPROM Erase Flow Erase • Set C register to 1CH Parameter settings • Set HL register to start address of entry RAM (can be omitted if settings are not changed) •...
CHAPTER 3 ACCESS TO FLASH MEMORY 3.13 Status List Table 3-5 shows the list of the firmware statuses (return values). Table 3-5. Status List Status Description Normal end Parameter error (parameter setting error) FLMD0 error (write error due to abnormal FLMD0 levels) MRG10 error (erasure error) MRG11 error (internal verification error, blank check error) Write error (write error due to verification abnormality at READ level)
CHAPTER 3 ACCESS TO FLASH MEMORY μ 3.14 Boot Swap Function ( PD78F0714 only) If, during boot area rewrite, rewrite fails due to an instantaneous power supply interruption, etc., the data in the boot area is lost and the program cannot be restarted through reset. The boot swap function is provided to avoid this problem.
Page 58
CHAPTER 3 ACCESS TO FLASH MEMORY Figure 3-16. Boot Swap Execution Example 2 Block no. Block 2 erase Block 3 erase Block 3 and 4 write New boot Program Program Boot program cluster 1 New boot Program program 1 0 0 0 H Boot Boot Boot...
CHAPTER 4 CC78K0 SELF-WRITE EXPANSION FUNCTION The CC78K0 has self-write subroutine direct call functions in the firmware. Flash memory control firmware can be called by using the __hromcall function. The __hromcall function temporarily switches the register bank to bank 3, sets function numbers to C register and entry RAM addresses to HL register and calls the specified address.
Page 60
For further information, please contact: NEC Electronics Corporation 1753, Shimonumabe, Nakahara-ku, Kawasaki, Kanagawa 211-8668, Japan Tel: 044-435-5111 http://www.necel.com/ [Asia & Oceania] [America] [Europe] NEC Electronics (China) Co., Ltd NEC Electronics America, Inc. NEC Electronics (Europe) GmbH 7th Floor, Quantum Plaza, No. 27 ZhiChunLu Haidian 2880 Scott Blvd.
Need help?
Do you have a question about the uPD78F0711 and is the answer not in the manual?
Questions and answers