Home
Flash Self-Programming Library Type01 User`s Manual
Contents
1. 4 y C End flash self programming D RO1US0050EJ0103 Rev 1 03 Page 5 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 Figure 1 3 Example of Flow of Code Flash Memory Rewriting During Background Operation For preprocessing and end processing refer to Figure 1 2 Y lt 5 gt FSL_BlankCheck When rewriting of the code flash memory is performed in status check user mode Error Status check In execution v lt 11 gt FSL_StatusCheck In execution Blank check error Status check Normal completion lt 6 gt FSL_Erase Error Status check In execution gt A A lt 11 gt FSL_StatusCheck In execution Error Status check Normal completion aj AA lt 7 gt FSL_Write Error Status check gt In execution gt y lt 11 gt FSL_StatusCheck In execution Error Status check gt Normal completion v lt 8 gt FSL_IVerify Error Status check gt In execution gt y lt 11 gt FSL_StatusCheck In execution Status check Processing complete R01US0050EJ0103 Rev 1 03 Page 6 of 109 Dec 22 2014 7tENESAS RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 lt 1
2. Note on the internal reset was added RO1USO050EJ0103 Rev 1 03 Page 109 of 109 Dec 22 2014 2RENESAS RL78 Microcontrollers User s Manual Flash Self Programming Library Type 01 Publication Date Rev 1 03 Dec 22 2014 Published by Renesas Electronics Corporation CENESAS SALES OFFICES Renesas Electronics Corporation http www renesas com Refer to http Awww renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 49 211 6503 0 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Room 1709 Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100191 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Tel 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Ed
3. CALL _FSL_PrepareFunctions or CALL _FSL_PrepareFunctions Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Prepares the following functions for use FSL_BlankCheck FSL_Erase FSL_Write FSL_IVerify FSL_StatusCheck FSL_StandBy FSL_WakeUp Register State After Call The register is not destructed Argument None Return Value None a cert aaa Rev 1 03 RENES AS Page 60 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_PrepareExtFunctions Overview Preparation for use of the flash functions extension function functions requiring RAM execution Format lt C language gt fsl_u08 FSL_PrepareExtFunctions fsl_ul block_ul6 lt Assembler gt CALL _FSL_PrepareExtFunctions or CALL _FSL_PrepareExtFunctions Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function and FSL_PrepareFunctions function must be completed normally Function Prepares the following functions for use FSL_SwapBootCluster FSL_SwapActiveBootCluster FSL_InvertB
4. Execute Code flash memory cannot be referred to during this period On going Ret BUSY Execute Finish qe oe aooo Dec 22 2014 RENESAS RL78 Family Flash Self Programming Library Type 0 control is not returned to the user program until the corresponding processing of the sequencer is complete Because the control returns to the user program after the control of the code flash memory is completed the user program and flash self programming can be allocated on the ROM To use this mode select the status check internal mode when initializing the Flash Self However if it is required to receive an interrupt during the control of the code flash memory the branch destination of the interrupt and interrupt processing must be allocated on the RAM ROM part of the flash functions cannot be used For details of the flash functions refer to CHAPTER 6 FLASH FUNCTION Figure 2 3 Example 2 Rewrite Control o CHAPTER 2 PROGRAMMING ENVIRONMENT 1 After an execution request of the desired processing is made to the sequencer of the RL78 microcontroller the Programming Library Type 01 f Flash When User Program Does Not Operate during Rewrite User program Library Sequencer Ret Execute On going Execute Code flash memory cannot be referred to during this period On going Execute Finish RO1US0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS If they ar
5. Overview Setting of the boot area rewrite protection flag to protected Format lt C language gt fsl_u08 FSL_SetBootClusterProtectFlag void lt Assembler gt CALL _FSL_SetBootClusterProtectFlag or CALL _FSL_SetBootClusterProtectFlag Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Sets the boot area rewrite protection flag to protected When itis set to protected swapping erasure and writing to the boot cluster cannot be done Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Register State After Call Development tool Destructed register RENESAS a S ee Argument None a ae vie 03 Rev 1 03 RENESAS Page 95 of 109 RL78 Family
6. Call this function in the beginning of flash self programming operation Register State After Call The register is not destructed Argument None Return Value None a cert ala Rev 1 03 RENES AS Page 58 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_ Close Overview End declaration of flash self programming ending of the flash environment Format lt C language gt void FSL_Close void lt Assembler gt CALL _FSL_Close or CALL _FSL_ Close Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Performs end declaration of flash self programming ending of the flash environment It ends write operation to the code flash memory and returns to the normal operation mode Register State After Call The register is not destructed Argument None Return Value None a cert ala Rev 1 03 RENES AS Page 59 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_PrepareFunctions Overview Preparation for use of the flash functions standard rewrite functions requiring RAM execution Format lt C language gt void FSL_PrepareFunctions void lt Assembler gt
7. Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model near fsl_write_t write_pstr AX 0 15 ees ee The start address of the variable 16bit RENESAS Large model near fsl_write_t write_pstr X 0 15 oe a The start address of the variable 16bit a cert aaa Rev 1 03 RENESAS Page 73 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x05 FSL_ERR_PARAMETER Parameter error The start address is not a multiple of 1 word 4 bytes The written data count is 0 The written data count exceeds 64 words The write end address start address written data count x 4 bytes exceeds the code flash memory area 0x10 FSL_ERR_PROTECTION Protect error The specified range includes the boot area and the boot area rewrite permission flag is set to protected The specified block is outside the FSW setting area 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing Ox1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution st
8. Flash self programming is in the pause state Note Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 82 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetFlashShieldWindow Overview Acquisition of the start block number and end block number of the flash shield window Format lt C language gt fsl_u08 FSL_GetFlashShieldWindow __near fsl_fsw_t getfsw_pstr lt Assembler gt CALL _FSL_GetFlashShieldWindow or CALL _FSL_GetFlashShieldWindow Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Obtains the start block and end block of the flash shield window and inputs the values to the data storage buffers start_block_pu16 start block and end_block_pu16 end block specified in the argument respectively Register State After Call Development tool Destructed register RENESAS e o Argument Definition of argument near fsl_fsw_t getfsw_pstr FSW start and end block storage buffer Reserve a dedicated data buffer Definition of _near fsl_fsw_t Development tool C language Assembly language Example of definition RENESAS typedef struct _getfsw_pstr fsl_u16 fsl_start_block_u16 _fsl_start_block_u1
9. Q00CDH On chip debug security ID 00C00H Block 3 000C4H setting area 10 bytes Block 2 ia Option byt 00800H te Boot cluster 0 000C0H pronayes Block 1 O00BFH GALLT table 64 byt 00400H oc 00080H able 64 bytes 0007FH 00000H Block 0 _ 00000H _ 00000H Vector table 128 bytes 01000H oe aaeeeo Dec 22 2014 RENESAS lt R gt RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 1 3 Processing time of flash self programming This section describes the time required to process the Flash Self Programming Library Type 01 functions The number of clock cycles required to execute flash functions differs depending on whether the flash functions are allocated to the internal ROM area flash memory or they are allocated to the internal RAM area When the functions are executed in the RAM the processing time may increase to a maximum of double the time needed when they are executed in the ROM This section shows the processing time when the FSL_RCD segment is executed in the RAM and the other segments are executed in the ROM For each segment of flash functions see Table 6 2 Segment List of Flash Functions 1 Flash self programming library function processing time in status check user mode The flash self programming library function processing time is the time required from when a user created program calls a flash function until the processing ends and control returns to the user created program The fla
10. ae An error occurred during erasure processing 0x1C FSL_ERR_WRITE Internal verification error An error occurred during verification internal verification processing 0x1F FSL_ERR_FLOW Writing error An error occurred during write processing OxFF FSL_BUSY Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Note2 Flash self programming is in the pause state Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 99 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_StatusCheck Overview Checking of the operation state of the flash function Format lt C language gt fsl_u08 FSL_StatusCheck void lt Assembler gt CALL _FSL_StatusCheck or CALL _FSL_ StatusCheck Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM This function can be used only in the status check user mode
11. Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Remark Erasure is performed only for one block To erase multiple blocks call this function multiple times Register State After Call Development tool Destructed register Renesas de S o O a cert aaa Rev 1 03 RENESAS Page 68 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Argument Definition of argument block_u16 Block number of the block to be erased Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u16 block_u16 AX 0 15 Block number 16bit RENESAS Large model fsl_u16 block_u16 AX 0 15 Block number 16bit Return Value State Description 0x00 FSL_OK Normal completion 0x05 FSL_ERR_PARAMETER Parameter error The specification of the block number is outside the allowable setting range 0x10 FSL_ERR_PROTECTION Protect error The specified block is included in the boot area and the boot area rewrite permission flag is set to be protected The specified block
12. Definition of argument block_u16 Block number to be verified Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u16 block_u16 AX 0 15 Block number 16bit RENESAS Large model fsl_u16 block_u16 AX 0 15 Block number 16bit Return Value State Description 0x00 FSL_OK Normal completion 0x05 FSL_ERR_PARAMETER Parameter error The specification of the block number is outside the allowable setting range 0x1B FSL_ERR_IVERIFY Verification internal verification error An error occurred during verification internal verification processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been Note2 completed The prerequisite defined in presetting is violated Note2 Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode Ee a T Rev 1 03 RENESAS Page 71 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_Write Overview Writing of 1 to 64 word data into the specified address 1 word 4 bytes Format lt C language gt fsl_u08 FSL_Write
13. Example 1 Writing in the status check user mode Because it returns immediately other processing can be executed However the ROM cannot be referred to until writing is complete Also the status must be checked until it is complete The user can check completion here User Library Function executed Function closed Writing Status check processing gt ROM cannot be referred to Status check a Status check J Example of Status Check Mode Example 2 Writing in the status check internal mode It doesn t return during the write but control is easy Interrupts must be received by the RAM until the processing is complete as in the user mode User Library Function executed Function end lt Writing processing ROM cannot be referred to Note Only the status check internal mode can be used for the segment FSL_RCD of some flash functions with user restrictions on the allocation on the ROM or when the user program is allocated on the ROM RO1USO050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 46 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Table 6 4 List of Status Checking of Flash Functions FSL_PrepareFunctions Not required FSL_PrepareExtFunctions FSL_ChangelnterruptTable FSL_RestorelnterruptTable FSL_BlankCheck FSL_Erase Required FSL_IVerify FSL_Write FSL_GetSecurityFlags FSL_GetBo
14. Function Checks the start of operation continuity and status of the flash function executed immediately before Register State After Call Development tool Destructed register Renesas de S o O Argument None R01US0050EJ0103 Rev 1 03 Page 100 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE 0x1B FSL_ERR_IVERIFY 0x1B FSL_ERR_BLANKCHECk 0x1C FSL_ERR_WRITE 0x1F FSL_ERR_FLOW 0x30 FSL_ERR_IDLE OxFF FSL_BUSY Erasure error An error occurred during erasure processing Internal verification error An error occurred during verification internal verification processing Blank check error The specified block is not in the blank state Writing error An error occurred during write processing Flow error The prerequisite defined in presetting is violated Flash self programming is in the pause state Non execution error The processing being executed does not exist Note Flash function in execution The flash function is in execution Note Only in the status check user mode RO1USO0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 101 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_StandBy Overview Suspension of erasure processing FSL_Erase and pa
15. use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Sets the block erasure protection flag to protected Block erasure to the device by the programmer cannot be done Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Register State After Call Development tool Destructed register Renesas de d o Argument None R01US0050EJ0103 Rev 1 03 Page 91 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE Erasure error An error occurred during erasure processing 0x1B FSL_ERR_IVERIFY Internal verification error An error occurred during verification internal verification processing 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the
16. 0 rewrite prohibition flag is 1 permitted Remark If the Boot cluster 0 rewrite prohibition flag is O prohibited an error occurs when the FSL_InvertBootFlag function is called in lt 6 gt RO1USO050EJ0103 Rev 1 03 Page 38 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 lt 6 gt Setting of the boot swap bit Switching of the boot flag is performed by executing the FSL_InvertBootFlag function lt 7 gt Occurrence of an event When a reset is generated Boot Cluster 1 becomes the boot program area Program area Boot Boot cluster 1 cluster 0 On chip debug security ID setting area Option byte Program area Boot Boot cluster 0 On ee debug security ID cluster 1 ee area Option byte CALLT table Vector table lt 8 gt Ending of swap processing Boot Cluster 1 Swap processing for Boot Cluster 1 is finished after the operations lt 2 gt to lt 7 gt If Boot Cluster 0 doesn t have to be rewritten end processing If Boot Cluster 0 has to be rewritten perform the processing of lt 9 gt and on lt 9 gt Preprocessing The same processing as lt 1 gt is performed RO1USO050EJ0103 Rev 1 03 Page 39 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 lt 10 gt Erasure of Boot Cluster 0 All the blocks of Boot Cluster 0 are erased by calling the FSL_Erase function Prog
17. 01 CHAPTER 6 FLASH FUNCTION 6 3 Interrupts and BGO background operation The flash functions can be divided into processing that does not use the sequencer and processing that uses the sequencer which have different interrupt reception methods background operation can be performed For the processing that uses the sequencer BGO The following table shows a list of the flash functions with the presence of sequencer control and their interrupt reception areas Table 6 3 List of Interrupt Reception Areas and BGO of Flash Functions Interrupt i Function name Sequencer control er BGO function reception FSL_GetSwapState FSL_GetBlockEndAddr FSL_GetFlashShieldWindow FSL_SwapBootCluster ROM Allowed RAM Allowed Not allowed ROM Not allowed RAM Allowed ROM Allowed RAM Allowed Not allowed Yes Only on the RAM FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_ForceReset FSL_GetVersionString ROM Not allowed RAM Allowed Yes Only on the RAMN ROM Allowed RAM Allowed Notes 1 Whether or not interrupt reception during the execution of the function or during sequencer control is allowed ROM Normal vector interrupt RAM Interrupt on the RAM 2 To execute BGO the user program and part of the library must be allocated on th
18. 5 When the FSL_ChangelnterruptTable function is executed with the interrupt destination changed interrupts will enter the area changed by the FSL_ChangelnterruptTable function after moving to the address registered to the reset vector To move to the address registered to the reset vector in the restored state execute the FSL_RestorelnterruptTable function before the execution to restore the interrupt destination 6 If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted a ae vie 03 Rev 1 03 RENESAS Page 85 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Register State After Call Development tool Destructed register Renesas e d o o Argument None Return Value 0x10 FSL_ERR_PROTECTION Protect error Boot swapping was tried in the boot area rewrite protection state 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Note Flash self programming is in the pause state Note Only in the status check user m
19. CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE Erasure error An error occurred during erasure processing 0x1B FSL_ERR_IVERIFY Internal verification error An error occurred during verification internal verification processing 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 96 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SetFlashShieldWindow Overview Setting of the flash shield window Format lt C language gt fsl_u08 FSL_SetFlashShieldWindow __near fsl_fsw_t setfsw_pstr lt Assembler gt CALL _FSL_SetFlashShieldWindow or CALL _FSL_SetFlashShieldWindow Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetti
20. FSI L StatusCheck 2 Code size when allocating some functions to RAM when using BGO Table 2 11 shows the code size required when using the background operation BGO feature during flash self programming When using the BGO feature the FSL_RCD segment must be allocated to RAM To copy the FSL_RCD segment to RAM the program must be ROMized Therefore an additional ROM capacity equivalent to the FSL_RCD segment size is required Table 2 11 Code Size When Allocating Some Functions to RAM Conditions RAM Size Bytes ROM Size Bytes Code size when all functions are registered 447 FSL_RCD 805 size of program that must be ROMized 447 Code size when all the following functions are 66 FSL_RCD 434 size of program that used must be ROMized 66 eFSL Init e FSL Open e FSL Close e FSL PrepareFunctions e FSL BlankCheck e FSL Erase e FSL IVerify e FSL Write e FSL StatusCheck Remark R01US0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS The above table only describes the code size of the flash self programming library When using BGO the user created program must be allocated to RAM and therefore a RAM capacity equivalent to the user created program is also required Moreover a RAM capacity equivalent to the program ROMized and copied to RAM is required For details about ROMization see user s manual of the development tools to be used Page 27 of 109 RL78 Family CHAPTER 2 PROGRAMMING E
21. FSL_SwapBootCluster FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag Execution of boot swapping and jumping to the registered address of the reset vector Inverting of the current value of the boot flag and execution of boot swapping Inverting of the current value of the boot flag Setting of the block erasure protection flag to protected FSL_SetWriteProtectFlag Setting of the write protection flag to protected FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_StatusCheck FSL_StandBy FSL_WakeUp FSL_ForceReset FSL_GetVersionString Setting of the boot cluster rewrite protection flag to protected Resetting of the microcontroller in use Version acquisition processing of the flash self programming library Note Only basic functions are supported for RL78 G12 L12 G1E group Other functions are not supported RO1USO0050EJ0103 Rev 1 03 RENESAS Page 42 of 109 Dec 22 2014 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 6 2 Segments of Flash Functions The flash functions are divided into the following segments FSL_FCD A group of functions that initialize the environment They can be allocated to the ROM or RAM FSL_FECD A group of functions that read security information etc They can be allocated to the ROM or RAM FSL_RCD A group of functions required to rewrite the flash They can be allocated to the RAM There a
22. Function Processing Time in Status Check Internal Mode FSL Write FSL Flash function processing time Min Max Status OK RO1USO050EJ0103 Rev 1 03 Page 17 of 109 Dec 22 2014 ztENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Table 2 3 Flash Function Processing Time in Status Check Internal Mode Full Speed Mode FSL_Functions lt R gt 3302 folk 84 4833 foLk 164 4877 folk 163 73339 foLk 255366 10474 folk 1107 3121 fcLk 66 3121 fcLk 66 595 fok 60 x W 1153 folk 561 x W T T sak 1 1938 folk 50 141314 fcLk 513862 1565 folk 18 140940 fcLk 513830 1571 fcLk 18 140946 folk 513830 1569 fcLk 18 140945 folk 513830 1571 fcLk 18 140946 fcLk 513830 1356 folk 18 140739 fcuk 513830 Remarks 1 fck CPU operating frequency For example when using a 20 MHz clock fck is 20 2 W The number of words to be written 1 word 4 bytes For example when specifying 2 words 8 bytes W is 2 RO1USO050EJ0103 Rev 1 03 Page 18 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 lt R gt Table 2 4 Flash Function Processing Time in Status Check Internal Mode Wide Voltage Mode FSL_Functions 3298 fcLk 124 4574 fcLk 401 4675 folk 401 64468 foLk 266193 7659 fol
23. G13 product with 4 Kbyte RAM and 64 Kbyte ROM RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Table 2 8 Stack Size Used by Flash Functions Function Name Function Name L Init L GetBlockEndAddr L Open L_GetFlashShieldWindow L Close L SwapBootCluster L_PrepareFunctions L_SwapActiveBootCluster L PrepareExtFunctions L InvertBootFlag L ChangeInterruptTable L SetBlockEraseProtectFlag L_RestoreInterruptTable L_SetWriteProtectFlag L BlankCheck L SetBootClusterProtectFlag Erase L SetFlashShieldWindow L IVerify L StatusCheck L Write L StandBy L GetSecurityFlags L WakeUp L GetBootFlag L ForceReset L_GetSwapState L_GetVersionString lt R gt Note Each size does not include the stack size used by the caller to call the FSL function Table 2 9 Data Buffer Size Used by Flash Functions Function Name Function Name L GetBlockEndAddr L_GetFlashShieldWindow oO T L Init L Open L Close L SwapBootCluster L_PrepareFunctions L_SwapActiveBootCluster L PrepareExtFunctions L InvertBootFlag L ChangeInterruptTable L SetBlockEraseProtectFlag L RestoreInterruptTable L SetWriteProtectFlag L BlankCheck L SetBootClusterProtectFlag L SetFlashShieldWindow Eras
24. __near fsl_write_t write_pstr lt Assembler gt CALL _FSL_ Write or CALL _FSL Write Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Before calling this function save the data to be written to the code flash memory in the data buffer Function Writes to the code flash memory of the specified address For the block to which writing has been performed always execute FSL_IVerify after the write Execute the FSL_Write function only to an erased block Up to 256 bytes in units of 4 bytes of data can be written at once In the following cases the specified word count or address is outside of the allowable setting range a parameter error 05H is returned Word count check 0 word 65 words or more Address check Not in units of 4 bytes from the beginning address The write end address exceeds the final address of the code flash memory Notes 1 After the data write execute verification internal verification of the block including the range to which the write is done Otherwise the written data is not guaranteed 2 If both of
25. cert ala Rev 1 03 RENES AS Page 78 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetSwapState Overview Acquisition of the swap state Format lt C language gt fsl_u08 FSL_GetSwapState fsl_u08 destination_pu08 lt Assembler gt CALL _FSL_GetSwapState or CALL _FSL_GetSwapState Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Obtains the current boot cluster swap state and inputs the value to the data storage buffer specified in the argument Register State After Call Development tool Destructed register RENESAS eo o d o Argument Definition of argument destination_pu08 Data storage buffer Reserve a dedicated data buffer Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u08 destination_pu08 X 0 15 The start address of the data buffer 16bit fsl_u08 destination_pu08 X 0 15 The start address of the data buffer 16bit a cert aaa Rev 1 03 RENESAS Page 79 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_Ok Normal completion 0x1F FSL_ERR_FLOW Flow
26. error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state Note Only in the status check user mode Boot swap status The boot flag is written to the data storage buffer destination_pu16 passed in the argument The current boot area OOOOH OFFFH is Boot Cluster 0 The current boot area OQOOOH OFFFH is Boot Cluster 1 Remark For the status of the boot area after the reset refer to the section on the FSL_GetBootFlag function a cae ve 03 Rev 1 03 RENESAS Page 80 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetBlockEndAddr Overview Acquisition of the final address of the specified block Format lt C language gt fsl_u08 FSL_GetBlockEndAddr __near fsl_getblockendaddr_t getblockendaddr_pstr lt Assembler gt CALL _FSL_GetBlockEndAddr or CALL _FSL_ GetBlockEndAddr Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Obtains the final address of the block specified in the argument and inputs the value to the data storage buffer Register State After Call Development tool Destru
27. is outside the FSW setting area 0x1A FSL_ERR_ERASE Erasure error An error occurred during erasure processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cert aaa Rev 1 03 RENESAS Page 69 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_IVerify Overview Verification internal verification of the specified block Format lt C language gt fsl_u08 FSL_IVerify fsl_ul6 block_ul6 lt Assembler gt CALL _FSL_IVerify or CALL _FSL_IVerify Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Performs verification to check
28. is required Pause released Erasure processing restarted ROM cannot Status check be referred End of processing End of Status check processing RO1USO0050EJ0103 Rev 1 03 ate Dec 22 2014 lt lt ENESAS Example 2 Pause processing during writing other than erasure processing User Library Writing executed gt Function closed Pause instruction Writing processing ROM cannot be referred to Pause state Pause state ROM can be Restart instruction reterred to Pause released lt Page 50 of 109 RL78 Family Flash Self Programming Library Type 01 CHAPTER 6 FLASH FUNCTION Table 6 5 List of Execution States of Stand by Function Sequencer control State when the stand by function is executed FSL_BlankCheck FSL_Erase FSL_IVerify FSL_Write FSL_GetSecurityFlags FSL_GetBootFlag FSL_GetSwapState FSL_GetBlockEndAddr FSL_GetFlashShieldWindow FSL_SwapBootCluster Not available Waits until the processing is complete and makes a transition to the pause state Pauses the erasure processing and makes a transition to the pause state Waits until the processing is complete and makes a transition to the pause state Not available FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_StatusCheck FSL_StandBy FSL_F
29. library consists of the following flash functions Table 6 1 List of Flash Functions Function name Description Basic function FSL_Init Initialization of the flash self programming environment o Starting of the flash environment start declaration of flash self programming O FSL_Close Ending of the flash environment end declaration of flash self programming o l FSL_PrepareFunctions Preparation processing for flash functions Oo FSL_PrepareExtFunctions Preparation processing for flash functions extension functions FSL_Prepare xtFunctions Preparation processing tor flash functions extension functions gt Interrupt vector change processing changing the interrupt destination from ROM to RAM Lee FSL_RestorelnterruptTable Interupt vector restoration processing changing the interrupt destination from RAMto ROM PFS BlkCheck _ _ dBlankcheskngofthespeciedbock O o Foc eese Seesweomeseteow SSCSC S dCC d Verification internal verification of the specified block Oo Writing of 1 to 64 word data into the specified address 1 word 4 bytes Oo FFSi_GetsecuniFags Aeqistion ofsecuty norman Fst etsoa acoustonotboottegmomaon T CS Fs GeSwapsers Aeausnonotswap morman Tooo Fst GeBiockEndadar Reqistion othe fal acess of tne spected FSL GetFlasnsrielaWindow Acauistion athe start block number and end block number ofthe fash srie wndow
30. lt Assembler gt CALL _FSL_ForceReset or CALL _FSL_ForceReset Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting None Function Executes the command code of FFH to generate an internal reset of the RL78 microcontroller in use Cautions 1 The RL78 microcontroller in use is reset so the processing after this function is not executed 2 When this function is executed while E1 or IECUBE is being used a break occurs and processing stops Normal operation cannot be done after the occurrence of a break Execute a manual reset 3 For the internal reset with the command code of FFH refer to the user s manual of the target RL78 microcontroller Register State After Call The register is not destructed Argument None Return Value None a cert aaa Rev 1 03 RENES AS Page 106 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetVersionString Overview Acquisition of the version of the flash self programming library Format lt C language gt __far fsl_u08 FSL_GetVersionString void lt Assembler gt CALL _FSL_GetVersionString or CALL _FSL_GetVersionString Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting None Function Obtains the beginning address
31. self programming library is not used the self RAM can be used as a normal RAM space 4 The data buffer is used as the working area for flash self programming library internal processing or the area where the data to be set is allocated in the FSL_Write function The required size depends on the function to be used RO1USO050EJ0103 Rev 1 03 Page 24 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Special function register SFR Tee F 4 Area where RAM stack data buffer etc used by FFEFFH neral PAPPP PAEA SADDR area the Flash Self Programming Library cannot be FFE20H ASA LLL LLLALALLLLML 4J allocated FFE1FH No allocation restriction RAM 4 Kbytes lt R gt FFSO0H OR OCROCOOOQOROOOODOOOOLOLS FF2FFH Area whose usage is prohibited Self RAM Area damaged when the Flash Self Programming Library is used pase FEEFFH Mirror Figure 2 10 Example 2 of Arrangement in RAM without Self RAM RL78 G13 product with 2 Kbyte RAM and 32 Kbyte ROM Special function register SFR ECeeed 7 Area where RAM stack data buffer etc used by PIJE ye PS 2 Ss SADDR area the Flash Self Programming Library cannot be FFE20H_ ZL LLLLALAALELAALALELLELEL allocated FFE1FH RAM 2 Kbytes yt No allocation restriction FEH FF6FFH Mirror R01US0050EJ0103 Rev 1 03 Page 25 of 109 Dec 22 2014 tENESAS Figure 2 9 Example 1 of Arrangement in RAM Including Self RAM RL78
32. status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Remarks 1 The FSL_BlankCheck function checks if the cell of the code flash memory satisfies the erasure level with a sufficient margin A blank check error does not indicate any problem in the code flash memory but perform erasure processing before performing writing after the blank check error 2 Ablank check is performed only for one block To perform blank checking of multiple blocks call this function multiple times Register State After Call Development tool Destructed register RENESAS oO a cert alae Rev 1 03 RENESAS Page 66 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Argument Definition of argument block_u16 Block number of the block to be blank checked Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u16 block_u16 AX 0 15 Block number 16bit RENESAS Large model fsl_u16 block_u16 AX 0 15 Block number 16bit Return Value State Description 0x00 FSL_OK Normal completion The specified block is in the blank state 0x05 FSL_ERR_PARAMETER Parameter error a 0x1B FSL_ERR_BLANKCHECK Bla
33. that has the version information of the flash self programming library Register State After Call Development tool Destructed register RENESAS BO 0 18 DE 16 31 O ee Argument None Return Value Data type Description eel_u08 Version information storage beginning address of the flash self programming library 32bit 24 byte area Example Flash Self Programming Library Type 01 SRL78T01R110GVxxx Version information Example V220 V2 20 Supported too RENESAS Type name Type 01 Supported device RL78 Target library FSL a cert aaa Rev 1 03 RENESAS Page 107 of 109 RL78 Family APPENDIX A REVISION HISTORY Flash Self Programming Library Type 01 APPENDIX A REVISION HISTORY A 1 Major Revisions in This Edition Description Classification Throughout the document The English translation was reviewed and corrected a The corresponding ZIP file name and release version were added to the cover d The target device descriptions were deleted c References to the list of the target MCUs were added e i The term voltage mode was changed to flash memory programming mode d for consistency of terminology _ Various types of operating frequency described in the former version were d unified to the CPU operating frequency s A description regarding boot cluster 0 was added to the boot area c Cha
34. the write level to the specified block The verification checks if the data written to the code flash memory of the specified block is in the erasure level Data 1 write level Data 0 In case of an error execute the FSL_Erase and then perform writing with FSL_Write again If the specified block number does not exist a parameter error 05H is returned Cautions 1 If no verification internal verification of the block including the range to which the write is done after a data write the written data is not guaranteed 2 Data erasure data write and internal verification are performed and completed normally after an internal verification error the device is determined as normal 3 If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Remark Verification is performed only for one block To perform verification of multiple blocks call this function multiple times Register State After Call Development tool Destructed register RENESAS oo a oa Rev 1 03 RENESAS Page 70 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Argument
35. to close the flash self programming library When using the flash self programming library after the execution of the EEPROM emulation library or data flash library the flash self programming processing must be started from the initialization function FSL_Init Do not execute the STOP or HALT instruction during the execution of flash self programming If the STOP or HALT instruction needs to be executed pause flash self programming with the FSL_StandBy function or execute processing up to the FSL_Close function to close flash self programming The watchdog timer does not stop during the execution of self programming In the status check internal mode do not make the watchdog timer interrupt interval shorter than the execution time of FSL_SetXxXxX FSL_SwapActiveBootCluster and FSL_InvertBootFlag The code flash memory cannot be read during code flash memory operation by flash self programming Do not allocate the data buffer arguments or stack used in the flash function to an area starting from address OxFFE20 OxFE20 When using the data transfer controller DTC during the execution of flash self programming do not allocate the RAM area used by the DTC to the self RAM or an area starting from address OxFFE20 OxFE20 Do not destroy the RAM area including self RAM used by flash self programming until flash self programming is complete Do not execute a flash function within interrupt processing The flash function doe
36. 09 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_Ok Normal completion 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state Note Only in the status check user mode Security bit information The security bit is written to the data storage buffer destination_pu16 passed in the argument Bit 1 Ob000000X0 Boot area rewrite protection flag 0 Protected 1 Permitted Bit 2 Ob00000X00 Block erasure protection flag 0 Protected 1 Permitted Bit 4 0b000X0000 Write protection flag 0 Protected 1 Permitted Other bits a cert ala Rev 1 03 RENESAS Page 76 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetBootFlag Overview Acquisition of boot flag information Format lt C language gt fsl_u08 FSL_GetBootFlag fsl_u08 destination_pu08 lt Assembler gt CALL _FSL_GetBootFlag or CALL _FSL_GetBootFlag Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Obtains the boot cluster flag information and inp
37. 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Remark To write data over 256 bytes call this function multiple times a oer aaa Rev 1 03 RENESAS Page 72 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Register State After Call Development tool Destructed register Renesas de S d o Argument Definition of argument Argument Description near fsl_write_t write_pstr Write data storage buffer Reserve a dedicated data buffer Definition of__near fsl_write_t Development tool C language Assembly language Example of definition RENESAS typedef struct _descriptor_pstr fsl_u08 __ near fsl_data_buffer_p u08 fsl_data_buffer_p_u08 fsl_u32 fsl_destination_address_u32 fsl_destination_address_u32 fsl_u08 fsl_word_count_u08 _fsl_word_count_u08 fsl_write_t The content of fsl_write_t fsl_u08 __ near fs _data_buffer_p_u08 Beginning address of the buffer area where data to write is input fsl_u32 fsl_destination_address_u32 Beginning address of the destination fsl_u08 fsl_word_count_u08 Data count to write 1 64 in words
38. 4 FSL_PrepareExtFunctions FSL_ChangelnterruptTable FSL_RestorelnterruptTable FSL_BlankCheck When block is blanked 1310 fcLk 335 1289 fcLk 335 FSL_Erase When block is not blanked FSL_IVerify FSL_Write FSL_GetSecurityFlags FSL_GetBootFlag FSL_GetSwapState FSL_GetBlockEndAddr FSL_GetFlashShieldWindow FSL_SwapBootCluster FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_StatusCheck FSL_StandBy When block is blanked When block is not blanked FSL_WakeUp FSL_ForceReset FSL_GetVersionString 2689 fcLk 6959 4366 fcLk 7468 67 fcLK 112 5728 fcLk 8445 1289 fcLk 335 2689 fcLk 6959 fck CPU operating frequency For example when using a 20 MHz clock fck is 20 The value shown for the FSL_Write function indicates the recommended interval per 4 bytes RENESAS Page 23 of 109 RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 2 Software Environment Because the flash self programming library program needs to be allocated to a user created program area the size of the program code will be consumed in the program area To run the flash self programming library the CPU stack and data buffer are used Note1 2 Tables 2 7 lists the software resources required and Figures 2 9 and 2 10 show examples of arrangement in RA
39. 6 fsl_u16 fsl_end_block_u16 _fsl_end_block_u16 fsl_fsw_t a cert aaa Rev 1 03 RENESAS Page 83 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 The content of __near fsl_fsw_t fsl_u16 fsl_start_block_u16 FSW start block storage buffer Reserve a dedicated data buffer fsl_u16 fsl_end_block_u16 FSW end block storage buffer Reserve a dedicated data buffer Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model near fsl_fsw_t getfsw_pstr 0 15 E The start address of the variable 16 bit RENESAS Large model near fsl_fsw_t getfsw_pstr AX 0 15 eee The start address of the variable 16 bit Return Value 0x00 FSL_Ok Normal completion 0Ox1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Note Flash self programming is in the pause state Note Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 84 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SwapBootCluster Overview Execution of boot swapping and jumping to the registered address of the reset vector of the area after the swap Format lt C language gt fsl_u08 FSL_SwapBootCluster void lt Ass
40. C T o T lt V 5 C D O CENESAS RL78 Family Flash Self Programming Library Type01 Japanese Release ZIP file name JP_R_FSL_RL78_T01_Vx xx_x_E 16 Bit Single Chip Microcontrollers All information contained in these materials including products and product specifications represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp without notice Please review the latest information published by Renesas Electronics Corp through various means including the Renesas Electronics Corp website http Awww renesas com Renesas Electronics www renesas com Rev 1 03 Dec 2014 10 11 12 Notice Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in
41. FSL_ERR_IVERIFY 0x1C FSL_ERR_WRITE 0x1F FSL_ERR_FLOW 0x30 FSL_ERR_IDLE 0x43 FSL_SUSPEND Erasure error An error occurred during erasure processing before suspension Blank check error An error occurred during blank check processing before suspension Internal verification error An error occurred during verification internal verification processing before suspension Writing error An error occurred during write processing before suspension Flow errorN does not result in the pause state The prerequisite defined in presetting is violated Flash self programming is in the pause state Non execution error The processing being executed does not exist Pausing of the flash function The function of the flash function in execution is paused Notes 1 Only in the status check user mode 2 Only in pausing of erasure processing RO1USO0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 103 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_WakeUp Overview Canceling of the pause state to restart flash self programming Format lt C language gt fsl_u08 FSL_WakeUp void lt Assembler gt CALL _FSL_WakeUp or CALL _FSL_WakeUp Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execu
42. Further Renesas Electronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for a
43. M Table 2 7 Software Resources Used by Flash Self Programming Library Type 01 lt R gt Item Size Byte Restrictions on Allocation and Usage s The self RAM area used by RL78 Family Flash Self Programming Library Type 01 Ver Self RAMN 0 to 1024 3 2 20 differs depending on the device For details refer to RL78 Family Self RAM list of Flash Self Programming Library R20UT2944 Stack see Table 2 8 46 max Data buffer see Table 2 9 Arguments of library functions 1 to 256 Can be allocated to a RAM area other than the self RAM and the area from FFE20H to FFEFFH N Oto 8 Library size ROM 1 252 Can be allocated to a program area other than the self RAM and the area from FFE20H see Tables 2 10 max to FFEFFH and 2 11 RAM 0 to 447 Can be allocated to a program area other than the self RAM the area from FFE20H to FFEFFH and the internal ROM lt R gt Notes 1 For devices not shown in the RL78 Family Self RAM list of Flash Self Programming Library R20UT2944 contact your Renesas sales agency 2 The R5F10266 product does not support the self programming function 3 An area used as the working area by the flash self programming library is called self RAM in this manual and the Release Note The self RAM requires no user settings because it is an area that is not mapped and automatically used at execution of the flash self programming library previous data is discarded When the flash
44. NVIRONMENT Flash Self Programming Library Type 01 lt R gt RO1US0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS 2 2 1 Self RAM The flash self programming library may use a RAM area of 1 Kbyte as the working area This area is called the self RAM The data used in the self RAM is defined within the library so no user definition is required When a flash self programming library function is called the data in the self RAM area is rewritten The self RAM area used for flash self programming varies depending on the microcontroller and the user RAM may be used in some devices In such a device the user needs to allocate the self RAM area to the user RAM be sure to allocate the self RAM area at linkage the area can be specified in the link directive file 2 2 2 Register bank The flash self programming library uses the general registers ES CS registers SP and PSW of the register bank selected by the user 2 2 3 Stack and data buffer The flash self programming library uses the sequencer to write to the code flash memory but it uses the CPU for pre setting and control Therefore to use the flash self programming library the stack specified by the user program is also required Remark To allocate the stack and data buffer to the user specified addresses the link directive is used e Stack In addition to the stack used by the user program the stack space required for flash functions must be reserved in advance and they must be
45. Products The following usage notes are applicable to all MPU MCU products from Renesas For detailed usage notes on the products covered by this document refer to the relevant sections of the document as well as any technical updates that have been issued for the products 1 Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual The input pins of CMOS products are generally in the high impedance state In operation with an unused pin in the open circuit state extra electromagnetic noise is induced in the vicinity of LSI an associated shoot through current flows internally and malfunctions occur due to the false recognition of the pin state as an input signal become possible Unused pins should be handled as described under Handling of Unused Pins in the manual 2 Processing at Power on The state of the product is undefined at the moment when power is supplied The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied In a finished product where the reset signal is applied to the external reset pin the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is
46. ails of the flash memory programming mode see the target RL78 microcontroller user s manual 2 1 2 Blocks The flash memory of the RL78 microcontroller is divided into 1 Kbyte blocks In flash self programming erasure processing blank check processing and verification internal verification processing are performed for the code flash memory in the units of the blocks To call these flash self programming library functions specify a block number The boot cluster is the area provided to prevent the user program from being unable to boot up due to destruction of the vector table data or program basic functions caused by an instantaneous power interruption or resetting during a rewrite while the area including the vector area is being rewritten For details refer to CHAPTER 5 BOOT SWAP FUNCTION Figure 2 4 shows block numbers and boot clusters Note To use this function the RL78 microcontroller supporting the boot swap function is required To find if your RL78 microcontroller supports the boot swap function refer to the user s manual of the target RL78 microcontroller S Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Figure 2 4 Example of Block Numbers and Boot Clusters RL78 G13 When Code Flash Memory Is 32 a Koytes o Boot swap target area ceooon Books 01800H Boot cluster 1 I l Program area I Block 4 000CEH eee OOFFFH
47. allocated so that the RAM used by the user will not be destroyed in stack processing during flash self programming operation The available range for stack specification is the internal RAM excluding the self RAM and addresses FFE20H FFEFFH For stack space required for the flash functions refer to the document Release note attached to the installer e Data buffer The data buffer is used as the working area used for flash self programming library internal processing or the area where the data to be set is allocated in the FSL_Write function The available range for the start address of the data buffer is the internal RAM excluding the self RAM and addresses FFE20H FFEFFH as in the stack Page 28 of 109 RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 2 4 Flash self programming library Not all the flash functions are linked Only the flash functions to be used are linked e Memory allocation of the flash self programming library Segments are assigned to the functions and variables used in the flash self programming library Areas used in the flash self programming library can be specified to the specific locations For details refer to 6 2 Segments of Flash Functions or refer to the document Release note attached to the installer Note For the assembly language linking can be done only for the flash functions to be used by deleting unnecessary functions from the include file 2 2 5 P
48. amily Flash Self Programming Library Type 01 CHAPTER 2 PROGRAMMING ENVIRONMENT Table 2 5 Recommended Interval of Status Check in Status Check User Mode Full Speed Mode Or e A e Remark Note R01US0050EJ0103 Rev 1 03 Dec 22 2014 FSL_PrepareExtFunctions FSL_ChangelnterruptTable FSL_RestorelnterruptTable FSL_BlankCheck When block is blanked 1569 fcLK 98 1490 fcLK 97 FSL_Erase When block is not blanked FSL_IVerify FSL_Write FSL_GetSecurityFlags FSL_GetBootFlag FSL_GetSwapState FSL_GetBlockEndAddr FSL_GetFlashShieldWindow FSL_SwapBootCluster FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_StatusCheck FSL_StandBy When block is blanked When block is not blanked FSL_WakeUp FSL_ForceReset FSL_GetVersionString 3092 fcLk 647 7181 fcLk 1041 72 fcLK 60 6431 fcLk 7053 1490 fcLk 97 3092 fcLK 6471 fck CPU operating frequency For example when using a 20 MHz clock fck is 20 The value shown for the FSL_Write function indicates the recommended interval per 4 bytes RENESAS Page 22 of 109 RL78 Family Flash Self Programming Library Type 01 Table 2 6 Recommended Interval of Status Check in Status Check User Mode Wide Voltage Mode CHAPTER 2 PROGRAMMING ENVIRONMENT e e A e Remark Note R01US0050EJ0103 Rev 1 03 Dec 22 201
49. as Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended 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 which the product is not intended by Renesas Electronics You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions
50. as added The names of functions were clearly stated in the overall description Notes on rewriting were added Notes on internal verification were added State when the FSL_Close function is executed was added Notes on the interrupt were added Chapter 2 Programming Description of the mode selection was added to the example of controlling rewriting Environment of the flash memory Description of the initial setting was added Items regarding the processing time were added the description of the processing time was moved from the usage note to this document Items regarding the resources were added the description on the resources was moved from the usage note to this document Note on the frequency of the high speed on chip oscillator was added Note on the RAM parity error was added Note on the writing was added Description of the non supported product R5F 10266 was added Note on the interrupt was added Note on the boot swap function was added Note on the security setting was added Notes on the interrupt were added Chapter 3 Interrupts During Execution of Flash Self Programming Note on the security setting was added Chapter 4 Security Setting Tables of defining structures and tables of parameter contents were added Chapter 6 Flash Descriptions were added to the sections for assembler in the field of settings of arguments Function
51. ate with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cert ala Rev 1 03 RENESAS Page 74 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_GetSecurityFlags Overview Acquisition of security information Format lt C language gt fsl_u08 FSL_GetSecurityFlags fsl_ul6 destination_pul6 lt Assembler gt CALL _FSL_GetSecurityFlags or CALL _FSL_GetSecurityFlags Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function and FSL_Open function must be completed normally Function Obtains the security flag information and inputs the value to the data storage buffer specified in the argument Register State After Call Development tool Destructed register RENESAS C Argument Definition of argument destination_pu16 Data storage buffer Reserve a dedicated data buffer Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u16 destination_pu16 X 0 15 The start address of the data buffer 16bit RENESAS Large model fsl_u16 destination_pu16 X 0 15 en a The start address of the data buffer 16bit a cert aaa Rev 1 03 RENESAS Page 75 of 1
52. auto_status_check_u08 Setting of the status check mode Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_descriptor_t descriptor_pstr AX 0 15 C 16 23 The start address of the variable 24bit RENESAS Large model fsl_descriptor_t descriptor_pstr AX 0 15 C 16 23 The start address of the variable 24 bit a cert aaa Rev 1 03 RENESAS Page 56 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_Ok Normal completion Initial setting is complete 0x05 FSL_ERR_PARAMETER Parameter error The frequency value is outside the allowable setting range The high speed on chip oscillator is not running a cert ala Rev 1 03 RENESAS Page 57 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_Open Overview Start declaration of flash self programming starting of the flash environment Format lt C language gt void FSL_Open void lt Assembler gt CALL _FSL_Open or CALL _FSL_Open Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function must be completed normally Function Performs start declaration of flash self programming starting of the flash environment
53. check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Register State After Call Development tool Destructed register Renesas de d o o Argument None a cert aaa Rev 1 03 RENESAS Page 93 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE Erasure error An error occurred during erasure processing 0x1B FSL_ERR_IVERIFY Internal verification error An error occurred during verification internal verification processing 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 94 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SetBootClusterProtectFlag
54. controller user programs and flash self programming library need to be allocated in the RAM to perform the processing depending on the control method In this document allocating the program for operating on the RAM in the code flash memory to use it is called ROMization To perform ROMization the functions such as the development tools need to be used e EEPROM emulation library Software library that provides the function to store data to the installed flash memory like an EERROM e Flash data library Software library to perform operation to the data flash memory RO1USO050EJ0103 Rev 1 03 Page 2 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 1 2 Calling Flash Self Programming Library To perform flash self programming the initialization processing for flash self programming and the functions corresponding to the functions used need to be executed from the user program by using the C language or assembly language In Flash Self Programming Library Type 01 when an operation to rewrite the code flash memory is performed the code flash memory cannot be referred to during the rewrite is executed Therefore part of the segment of the flash self programming library or the user program need to be allocated on the RAM depending on the usage method Figure 1 1 shows the state transition diagram of flash self programming Figure 1 2 shows an example of the code flash memory rewriting f
55. cted register RENESAS ed Argument Definition of argument __ near fsl_getblockendaddr_t End block address storage buffer getblockendaddr_pstr Reserve a dedicated data buffer Definition of __ near fsl_getblockendaddr_t Development tool C language Assembly language Example of definition RENESAS typedef struct _getblockendaddr_pstr fsl_u32 fsl_destination_address_u32 _fsl_destination_address_u32 fsl_u16 fsl_block_u16 _fsl_fsl_block_u16 fsl_getblockendaddr_t The content of fsl_getblockendaddr_t fsl_u32 fsl_destination_address_u32 End block address fsl_u16 fsl_block_u16 Block number a cert aia Rev 1 03 RENESAS Page 81 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Contents of argument settings Development tool Argument Type Register C language Assembly language RENESAS Small and medium model __near fsl_getblockendaddr_t X 0 15 ne ee The start address of the variable 16 bit RENESAS Large model __near fsl_getblockendaddr_t AX 0 15 ae ae The start address of the variable 16 bit Return Value 0x00 FSL_Ok Normal completion 0x05 FSL_ERR_PARAMETER Parameter error The specification of the block number is outside the allowable setting range Ox1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Note
56. e O Jo JO jo JO JO jo jo jo L IVerify L StatusCheck L Write 4 to 256 L StandBy L GetSecurityFlags 2 L WakeUp oO Jo jo jo A o jo jo jo jo joje L GetBootFlag 1 L ForceReset L GetSwapState L_GetVersionString Note The FSL_Write function requires an amount of memory equal to the data to be written in words For example when writing 2 words 1 word 4 bytes the required amount of memory is 2 x 4 8 bytes RO1USO050EJ0103 Rev 1 03 Page 26 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash S elf Programming Library Type 01 Flash Self Programming Library Code Size 1 Some functions cannot be used Code size when allocating all functions to ROM Table 2 10 shows the code size required when all flash self programming library functions are allocated to ROM Allocating the code to RAM is not required but usage restrictions will prevent some functions being used if all functions are allocated to ROM For details see 6 2 Segments of Flash Functions Table 2 10 Code Size When Allocating All Functions to ROM Conditions RAM Size Bytes ROM Size Bytes Code size when all functions are registered Code size when all the following functions are used e FS e FS e FS e FS e FS e FSL L Init L Open L Close L PrepareFunctions L BlankCheck Erase e FSI e FSI L IVerify L Write e
57. e RAM 3 The processing of this function does not have the BGO function because it checks the state of the sequencer or stops and restarts the sequencer control during block erasure RO1USO0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 45 of 109 RL78 Family Flash Self Programming Library Type 01 CHAPTER 6 FLASH FUNCTION 6 4 Status Check Mode For the functions that can perform background operation by using the sequencer a status check must be performed to check the control state to the code flash memory There are the following two modes of status checking which can be set with the FSL_Init function different status check methods Status check user mode Note They have After control setting of the sequencer is done by the flash function it returns to the user program The user needs to check the status of the sequencer with the status check function FSL_StatusCheck but the user program can be operated until the sequencer processing is completed The user programs and interrupt program to operate during sequencer control need to be allocated on the RAM Status check internal mode Note It doesn t return to the user program until the status of the sequencer is checked in the flash function and the sequencer processing is completed To operate interrupts during the execution of the function during sequencer control the interrupt program needs to be allocated on the RAM Figure 6 1
58. e allocated on the Page 11 of 109 RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 1 1 Initialization When rewriting the code flash memory by using the flash self programming library make the following settings 1 Starting high speed on chip oscillator During use of the flash self programming library keep the high speed on chip oscillator running When the high speed on chip oscillator is stopped start it before using the flash self programming library 2 Setting CPU operating frequency In order to calculate the timing in the flash self programming library set the CPU operating frequency at initialization See the description of the PFDL_Open function for the method for setting the CPU operating frequency 3 Setting flash memory programming mode In order to set the flash memory programming mode for erasing or writing either of the flash memory programming modes shown below should be specified when initializing the flash self programming library See the description of the FSL_Init function for the settings of the flash memory programming modes Full speed mode Wide voltage mode Notes 1 The CPU operating frequency is used as a parameter for the calculation of internal timing in the flash self programming library This setting does not affect the CPU operating frequency This is not the operating frequency for the high speed on chip oscillator 2 For det
59. e classifies revisions as follows a Error correction b Addition change of specifications c Addition change of description or note d Addition change of package part number or management division e Addition change of related documents RO1USO050EJ0103 Rev 1 03 Page 108 of 109 Dec 22 2014 2RENESAS RL78 Family APPENDIX A REVISION HISTORY Flash Self Programming Library Type 01 A 2 Revision History of Preceding Editions Here is the revision history of the preceding editions Chapter indicates the chapter of each edition Traper The document on the data flash library which was classified as the application note Throughout old version of RO1AN0350 was changed to the user s manual the document The corresponding installer and release version were added to the cover page Contents of the processing time and software resources were moved from the usage note to this document Accordingly the reference destination described in this document was also changed The supported device was added The notation of high speed OCO was deleted to unify the notation of high speed on chip oscillator The description of the operating frequency was unified to the CPU operating frequency since individual descriptions had different notations The state transition from prepared to extprepared was added to figure 1 1 Chapter 1 Overview Description on the FSL_PrepareFunctions function w
60. eaeeeeaaeseeaeeeeeeecaaeeeeaaeseeaeeseeeeesaeseeaaesseneeee 36 5 4 Cautions on Boot Swappin Giveitciesscaiivesesheciptecsbaneys iaaea aa ae araa a E Raae A ae araen aSa 41 CHAPTER 6 FLASH FUNCTION oo e ce eeeeecceecceeeeeeeeeeeeeaeeeeeeeeeeeeeseneaaeaeeeeeeeeeeeneee 42 6 Type ol Flash Functions Sear A A AAA E A AA 42 6 2 Segments of Flash FUNCTIONS meea aa aaiae narani aaae aan aaiae aa aae aaa aaa aia Eaa aiaa ii 43 6 3 Interrupts and BGO background operation c ccceccceeseeeeeneeeeeeee cae eeeeaeeeeeeeseeeeesaeeesaeeneneeeea 45 6 4 Status Check Modes ciel Gai aan gi et Gian aa eae eee 46 6 4 1 Status Check User Mode 0 ccceccceceeeceenceceeeeeceaeeeeaaeseeneeceeeeecaaesseaaesseeeseaeeseaaeseeneeesaes 48 6 5 Pausing of Flash Self Programming c ccccesceeeeceeeeeeeeeaeeeeneeseeeeeceaeeeeaaeseeeeeseeeesaeeesaeeeeneeeed 50 6 6 List of Data Types Return Values and Return TyPes ccccceeesseeeeeeeeneeeeeeeeeeeeeeaeeeeeeaeeeeneae 52 Index 1 6 7 Description of Flash FUNCtIONS 0 ccceeeceeeee eens eset eee ee eee ae ee ee eaaeeeeeeaaeeeeeeaaeeeeeeaeeeeesaeeeeeeaeeeeneaa 54 APPENDIX A REVISION HISTORY tsicccttcterctiicistarrecinccrtigieietiacen nan 108 A 1 Major Revisions in This Edition ccc cececeeeeeeeeeeeeeeeeeeeeeeeaeeeseeeaeeeeeeeaeeeseeaaeeeeeeaaeeeeeenaeeeeeeaaes 108 A 2 Revision History of Preceding Editions ssssseesessiessssinsssirrssirrnsinnnstinnssttnnnnt
61. embler gt CALL _FSL_SwapBootCluster or CALL _FSL_SwapBootCluster Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Sets to the interrupt protection DI and performs swapping of the boot clusters immediately after the execution of the function It moves to the address registered to the reset vector of the swapped area unlike the reset function of the RL78 microcontroller only the program execution from the reset vector address is performed Cautions 1 Do not execute this function in an RL78 microcontroller not supporting boot swapping 2 Before the execution of swapping always write the setting information required for operation after swapping such as the option byte to the area of the swap destination 3 When this function is executed normally the processing after this function is not executed because it moves to the address registered in the reset vector of the swapped boot cluster 4 This function does not invert the boot flag When a reset is performed the boot cluster is in the state according to the boot flag setting
62. estination to the original state Note Some RL78 microcontrollers do not support an interrupt during the execution of flash self programming Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports an interrupt during the execution of the flash self programming 3 2 Interrupts During Execution of Flash Self Programming Interrupts during code flash memory control cannot be received by the normal interrupt vector because the code flash memory cannot be referred to Therefore to receive interrupts they need to be received on the RAM Figure 3 1 Interrupts During Execution of Flash Self Programming On chip RAM lt Address of the RAM specified as the interrupt destination Beginning address of the interrupt function allocated Interrupt processing for the RAM Code flash memory After the interrupt destination is changed to the Code flash memory lt is being controlled RAM all interrupts branch to the same address For the details of interrupt the user needs to cannot be referred to check the interrupt flag No vector table is created automatically Normal interrupt vector Interrupts on the ROM cannot be received because the ROM cannot be used during the code flash memory is being controlled RO1USO050EJ0103 Rev 1 03 Page 32 of 109 Dec 22 2014 2tENESAS RL78 Family CHAPTER 3 INTERRUPTS DURING EXECUTION OF FLASH SELF PROGRAMMING Flash Se
63. function refer to the user s manual of the target RL78 microcontroller e Internal verification To check if the signal level of the flash memory cell is appropriate after writing to the flash memory If an error occurs in internal verification the device is determined as failed However if data erasure data writing and internal verification are performed and completed normally after the internal verification error the device is determined as normal e FSL Abbreviation of Flash Self Programming Library FSW Abbreviation of Flash Shield Window e Flash function Function comprising the flash self programming library RO1USO050EJ0103 Rev 1 03 Dec 22 2014 7tENESAS Page 1 of 109 RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 e Sequencer The RL78 microcontroller has a dedicated circuit for controlling the flash memory In this document this circuit is called the sequencer e BGO background operation State in which rewriting of the flash memory can be done while operating the user program by letting the sequencer to control the flash memory e Status check When the sequencer is used the processing to check the state of the sequencer state of control for the flash memory with the program controlling the flash memory is required In this document the processing to check the state of the sequencer is called status checking e ROMization program In flash self programming of the RL78 micro
64. g is being paused by the FSL_StandBy function Flash self programming can be restarted by using the FSL_WakeUp function When the pause occurred during the execution of the FSL_Erase function the processing of the FSL_Erase function is restarted RO1USO050EJ0103 Rev 1 03 Page 4 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 Figure 1 2 Example of Flow of Flash Self Programming Rewriting of Code Flash Memory C Start flash self programming D A A lt 1 gt FSL_Init Le No iad j 27 m Yes v lt 2 gt FSL_Open y lt 3 gt FSL_PrepareFunctions Pre processing v pe hie Use an terup maa eS v lt 4 gt FSL_ChangelnterruptTable FSL_BlankCheck When rewriting the code flash memory is performed in status check internal mode Status Blank check error L Other error Normal completion lt 6 gt FSL_Erase Status check gt __ Stat check _ Normal completion Se Status check Normal completion FSL_IVerify lt R gt Status check Normal completion Processing end pee No Changed the interrupt destination es Yes Ending processing y lt 9 gt FSL_RestorinterruptTable 4 y lt 10 gt FSL_Close
65. ge 49 of 109 RL78 Family Flash Self Programming Library Type 01 CHAPTER 6 FLASH FUNCTION 6 5 Pausing of Flash Self Programming When you need to pause the sequencer control during block erasure while the flash function is being executed in the status check user mode the stand by function FSL_StandBy can be used to pause the erasure processing to put flash self programming to the pause state When the stand by function is executed in a state other than during block erasure it waits until the previous processing is completed and makes a transition to the pause state after the completion When a transition to the pause state occurs the code flash memory cannot be controlled To return from the pause state the wakeup function FSL_WakeUp needs to be executed pause state is released to restart the block erasure If the block erasure is suspended the In other cases only the pause state is released Figure 6 4 Example of Pausing of Flash Self Programming Example 1 Pause processing during erasure processing User Library Start of Erasure executed Start of processing processing Function closed Erasure processing Pause instruction ROM cannot be referred to A transition to the pause Pause state state occurs after waiting for the completion of processing Pause state A transition to the ROM can be pause state occurs Restart insiruction referred to immediately if no waiting
66. ge processing FSL_ChangelnterruptTable End interrupt destination change processing a cert ala Rev 1 03 RENESAS Page 63 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_RestorelnterruptTable Overview Restoration of the interrupt destination changed to the RAM to the standard interrupt vector table Format lt C language gt fsl_u08 FSL_RestoreInterruptTable void lt Assembler gt CALL _FSL_RestoreInterruptTable or CALL _FSL_RestoreInterruptTable Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting None Function Restores the interrupt destination changed to the RAM to the standard interrupt vector table Cautions 1 If the interrupt destination is changed with the FSL_ChangelnterruptTable function the interrupt destination remains changed after flash self programming until a reset is performed unless the interrupt destination is restored with this function 2 When changing the interrupt destination to the standard interrupt vector with this function prohibit interrupts from the start to end Register State After Call The register is not destructed Argument None Return Value None a cert ala Rev 1 03 RENES AS Page 64 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Operation Example Start i
67. gt lt 2 gt lt 3 gt lt 4 gt lt 5 gt lt 6 gt lt gt lt 8 gt lt 9 gt lt 10 gt Initializing the RAM used for flash self programming The FSL_Init function is called to initialize the RAM used for flash self programming and to set the parameters required for the operation Starting the flash environment The FSL_Open function is called to make flash self programming available Preparation processing The FSL_PrepareFunctions function is called to prepare the functions used for flash self programming To use extension functions the FSL_PrepareExtFunctions function must also be called For details of the FSL_PrepareFunctions function and FSL_PrepareExtFunctions function refer to CHAPTER 6 FLASH FUNCTION Changing interrupt reception to the RAM When an interrupt is required during the execution of flash self programming the FSL_ChangelnterruptTable function is called to change the interrupt destination from the ROM to RAM Blank checking of the specified block 1 KB The FSL_BlankCheck function is called to perform a blank check of the specified block 1 KB Erasing the specified block 1 KB The FSL_Erase function is called to erase the specified block 1 KB Writing 1 to 64 word data to the specified address The FSL_Write function is called to write 1 to 64 word data to the specified address If writing to the specified block cannot be completed in one write the FSL_Write function is execu
68. gument fsl_u08 fsl_frequency_u08 The setting value is used for the calculation of timing data in the flash self programming library For the value of the operating frequency of the CPU fsl_frequency_u08 note the following Note4 is used as the operating frequency of the RL78 microcontroller 1 MHz When a frequency below 4 MHz 2 MHz or 3 MHz can be used a frequency such as 1 5 MHz that is not an integer value cannot be used Also set an integer value such as 1 2 or 3 as the operating frequency value set with the initialization function Note4 is used as the operating frequency of the RL78 microcontroller a When a frequency over 4 MHz frequency with decimal places can be used However set a rounded up integer value as the operating frequency set with the initialization function FSL_Init Example For 4 5 MHz set 5 with the initialization function The operating frequency is not the frequency of the high speed on chip oscillator e Set the status check mode in the argument fsl_auto_status_check uos For differences between the status check user mode and status check internal mode refer to 2 1 Hardware Environment or 6 4 Status Check Mode OOH Status check user mode Other than above Status check internal mode a oer aad Rev 1 03 RENESAS Page 55 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Notes 1 For the self RAM refer to the document Release note at
69. gument of this function Return Value Describes the return values from this function Flow FSL_SwapBootCluster function only Describes the internal flow of this function Operation Example FSL_ChangelnterruptTable and FSL_RestorelnterruptTable functions only Describes operation examples for using this function a cert aaa Rev 1 03 RENESAS Page 54 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL Init Overview Initialization of the flash self programming environment Format lt C language gt fsl_u08 FSL_Init _ far fsl_descriptor_t descriptor_pstr lt Assembler gt CALL _FSL_Init or CALL _FSL_Init Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting The flash self programming library program and data flash library to operate the data flash memory and EEPROM emulation library are not executed or have been ended e The high speed on chip oscillator is running Function Reserves and initializes the self RAM used for flash self programming Ifa self RAMN exists do not use it until flash self programming is finished Note of flash self programming in the argument Define the flash memory programming mode fsl_flash_voltage_u08 OOH Full speed mode Other than above Wide voltage mode e Set the operating frequency of the CPU in the ar
70. he flash self programming Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports the security setting function by the flash self programming lt R gt 18 Do not arrange the segment FSL_BCD and FSL_BECD in the final address of 64KB boundary 0x FFFE 0x FFFF when using the flash self programming library RO1USO050EJ0103 Rev 1 03 Page 31 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 3 INTERRUPTS DURING EXECUTION OF FLASH SELF PROGRAMMING Flash Self Programming Library Type 01 CHAPTER 3 INTERRUPTS DURING EXECUTION OF FLASH SELF PROGRAMMING 3 1 Overview Note However when the code flash Interrupt processing can be used even in the flash environment state memory is controlled the interrupt vector of a normal user application cannot be used The interrupt vector needs to be set to the RAM by using the interrupt vector change function FSL_ChangelnterruptTable Also the interrupt routine needs to be allocated on the RAM After the setting branching occurs to one vector on the RAM when all interrupts occur Therefore if there are multiple interrupt sources for which you want to execute different processing the interrupt sources need to be identified To restore the interrupt to the original vector state after the completion of the rewrite of the code flash memory use the interrupt vector restoration function FSL_RestorelnterruptTable to restore the interrupt d
71. innnntennnntennnnnnnn 109 Index 2 RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 RL78 Family RO1US0050EJ0103 Rev 1 03 Flash Self Programming Library Type 01 Dec 22 2014 CHAPTER 1 OVERVIEW 1 1 Overview The flash self programming library is software to rewrite data in the code flash memory with the firmware installed on the RL78 microcontroller The content of the code flash memory can be rewritten by calling the flash self programming library from the user program which can significantly shorten the software development period Use this Flash Self Programming Library User s Manual along with the manual of the target device Terms The meanings of the terms used in this manual are described below e Flash self programming Write operation to the code flash memory by the user program itself e Flash self programming library Library for code flash memory operation with the functions provided by the RL78 microcontroller Operation to the data flash memory cannot be done e Flash environment State in which operation to the code flash memory is available There are restrictions different from the execution of normal programs Operation to the data flash memory cannot be done e Block number Number indicating a block of flash memory Operation unit for erasure blank check and verification internal verification e Boot cluster Boot area used for boot swapping For the availability of the boot swap
72. iolated Flash self programming is in the pause state FSL_IDLE 0x30 Idle state Flash self programming is not executed FSL_SUSPEND 0x43 Pause state Flash self programming is paused FSL_BUSY OxFF Execution start of the flash function or the flash function in execution The function of the flash function is in execution a cert aaa Rev 1 03 RENESAS Page 52 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 The return types are as follows Table 6 8 List of Return Types Development tool C language Assembly language RENESAS Small and medium model fsl_u08 C RENESAS Large model S cert ala Rev 1 03 RENESAS Page 53 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 6 7 Description of Flash Functions The flash functions are described in the following format Flash function name Overview Describes the function overview of this function Format lt C language gt Describes the format to call this function from a user program described in the C language lt Assembler gt Describes the format to call this function from a user program described in the assembly language Presetting Describes the presetting of this function Function Describes the function details and cautions of this function Register State After Call Describes the register state after this function is called Argument Describes the ar
73. k 7534 3121 folk 66 3121 foLK 66 591 fotk 112 x W 1108 folk 1085 x W a sare ser z sak a 1938 foLk 50 124221 fk 538064 1565 folk 18 123847 fk 538032 1571 folk 18 123853 fk 538032 1569 folk 18 123852 foLk 538032 1571 folk 18 123853 fk 538032 1356 folk 18 123646 fk 538032 i Remarks 1 fck CPU operating frequency For example when using a 20 MHz clock fcuk is 20 e 2 W The number of words to be written 1 word 4 bytes For example when specifying 2 words 8 bytes W is 2 RO1USO050EJ0103 Rev 1 03 Page 19 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 3 Recommended interval of FSL_StatusCheck status check The FSL_StatusCheck function is used to check the status in the status check user mode However correct results cannot be obtained if the FSL_StatusCheck function is executed before control by the sequencer finishes Therefore spacing each process executed by each flash function by a specific time is useful to enhance the efficiency of status checking In addition because a write process using the FSL_Write function must be triggered by status check processing every 4 bytes the status must be checked each time 4 bytes are written When writing 12 bytes in the status check user mode the sequencer writes data in 4 byte units Therefore when 4 by
74. lf Programming Library Type 01 3 3 Cautions on Interrupts When changing the interrupt vector with the interrupt vector change function in the application prohibit interrupts from the start to the end of the switching procedure Do not specify a value over OxFFE20 as the change destination of the interrupt vector address Access to the code flash memory area is prohibited in interrupt processing during the execution of flash self programming The execution of flash functions is prohibited in interrupt processing Save and recover the register used in interrupt processing The interrupt source can be determined by referring to SFR interrupt request flag IF when an interrupt occurs on the RAM After the determination clear the interrupt request flag set 0 Interrupt processing on the RAM increases by up to 20 clocks compared to the normal interrupt response time To restore the original interrupt vector after the interrupt destination is changed with the interrupt vector change function the interrupt vector restoration function must be executed If the interrupt vector restoration function is not executed the interrupt destination will remain changed even when flash self programming is finished When a reset is done after the interrupt destination is changed with the interrupt vector change function the system starts up with the interrupt destination recovered Some RL78 microcontrollers do not suppor
75. low by using the flash self programming library Figure 1 3 shows an example of the code flash memory rewriting flow Figure 1 1 State Transition Diagram of Flash Self Programming Reset or Power ON am FSL_Init destroy RAM data FSL_SwapBootCluster FSL_ForceReset return FSL_PrepareFunctions FSL_Open FSL_Close FSL_PrepareExtFunctions FSL_ChangelnterruptTable FSL_RestorelnterruptTable FSL_Get FSL_ForceReset FSL_Wakeup Status OK Status ERROR FSL_StandBy l l FSL_SwapBootCluster l l I FSL_SwapActiveBootCluster Sa geal FSL_InvertBootFlag Status OK FSL_Verify FSL_Set Status ERROR FSL_Write FSL_StatusCheck _ I I j FSL_StandBy J acy y p Sequencer Control a FSL_Wakeup FSL_Erase Only RO1US0050EJ0103 Rev 1 03 Page 3 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 Overview of the state transition diagram To operate the code flash memory by using the flash self programming library the provided functions need to be executed sequentially to perform processing 1 uninitialized State at Power ON and Reset A transition to this state occurs also when the EEPROM emulation library or the flash data library is executed 2 closed State in which the FSL_Init function has been executed and the data to execute the flash self programming has been initialized operatio
76. n error An error occurred during verification internal verification processing 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 90 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SetBlockEraseProtectFlag Overview Setting of the block erasure protection flag to be protected Format lt C language gt Fsl_u08 FSL_SetBlockEraseProtectFlag void lt Assembler gt CALL _FSL_SetBlockEraseProtectFlag or CALL _FSL_SetBlockEraseProtectFlag Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete
77. n the right Active low representations xxx overscore over pin and signal name Note Footnote for item marked with Note in the text Caution Information requiring particular attention Remark Supplementary information Numerical representations Binary XXXx OF xxxxB Decimal XXX Hexadecimal xxxxH All trademarks and registered trademarks are the property of their respective owners EEPROM is a trademark of Renesas Electronics Corporation CONTENTS CHAPTER 1 OVERVIEW so scesecrenctsscscentcontecstrespencbs arreesbesspencysaesecboeenempracpouebneeeeeuedesiaes 1 Ws WOVOMVIOW seteces Pic E E seta bhte sete veld gh cance Stayt pibeah iad pated daetae beet E 1 1 2 Calling Flash Self Programming Library 0 c cccceesceeeeeeeeeeeeeeeeeeeeeeeeeaeeesaaeeeeaeeseeeeeseaeeseaeeeeneeees 3 CHAPTER 2 PROGRAMMING ENVIRONMENT ecceeeeceeeeeeeeeeeeeeeeneeeeeeeeeeeeeeeees 9 2 1 Hardware Envirnmenbassniiean a a a iei EEEE AEA ai aaa 9 E ET e a EEEE T A E ELE ATE TEE AE TE EE A E E TET 12 2o V2 BIOCKS cx tutceasievacdituaycaces S T A E EO 12 2 1 3 Processing time of flash self programMming sssssssssssssrssssrrsssrrssrirnssrinrsstennnstnnnnstnnnns 14 2x2 SOTtware ENVIONMENT repari ariede raara aa aa S Pat a eadapentcaSeprastepedtden readiness 24 22 Sel RAM tunin ia aeeai Ge Cleave edi ii iaa a iea 28 22a Registenbank ui E hte tal a a et 28 2 2 3 Stack and data Duff Cr eeeceec a a a a aa aa 28 2 2 4 Flash self
78. n to the code flash memory is stopped To execute the EEPROM emulation library or the flash data library STOP mode or HALT mode after operating the flash self programming execute FSL_Close from the opened state to make a transition to this state 3 opened State in which the FSL_Open function has been executed from the closed state and flash self programming can be executed This state is called the flash environment In the period from the execution of FSL_Close to the transition to the closed state the EEPROM emulation library or the flash data library STOP mode or HALT mode cannot be executed 4 prepaerd State in which the FSL_PrepareFunctions function has been executed from the opened state and operations to the code flash memory such as writing and erasure are enabled 5 extprepared State in which the FSL_PrepareExtFunctions function has been executed from the opened state and rewriting of the security flag and boot swap processing can be executed 6 busy State in which the specified processing is being executed The resulting transition may change depending on the executed function and end state 7 sequencer busy State in which the specified processing is being executed with the sequencer The code flash memory cannot be referred to while the sequencer is being used The resulting transition may change depending on the executed function and end state 8 standby State in which flash self programmin
79. nctions during the execution of flash self programming is the flash shield window function The flash shield window function is a security function that prohibits writing and erasure other than in the specified window range only during the execution of flash self programming The window range can be set by specifying the start block and end block The areas other than the window range are write protected and erasure protected during the execution of flash self programming FSL_SetFlashShieldWindow Sets the flash shield window RO1USO050EJ0103 Rev 1 03 Page 34 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 CHAPTER 5 BOOT SWAP FUNCTION 5 1 Overview When rewriting fails due to an instantaneous power interruption or resetting caused by an external factor while the area in which the vector table data program basic functions and the flash self programming library are allocated is being rewritten the data being rewritten is destroyed so restart or rewrite of the user program due to the subsequent reset cannot be done The boot swap function avoids this situation Note To use this function the RL78 microcontroller supporting the boot swap function is required To find if your RL78 microcontroller supports the boot swap function refer to the user s manual of the target RL78 microcontroller 5 2 Boot Swap Function Note with the boot swap target area Boot The bo
80. ng Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Sets the flash shield window Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Remark The flash shield window function is incorporated as a security function during the execution of flash self programming During the execution of flash self programming writing and erasure are permitted in the code flash memory in the range specified as the window but prohibited in the code flash memory outside the specified range However during on board off board programming writing and erasure are permitted in the code flash memory outside the range specified as the window When the range specified as the window and the rewrite protection area of Boot Cluster 0 overlap rewrite protection of Boot Cluster 0 has precedence Register State After Call Development tool Destructed
81. nk check error fee ee The specified block is not in the blank state 0Ox1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution function of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cert aaa Rev 1 03 RENESAS Page 67 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_Erase Overview Erasure of the specified block Format lt C language gt fsl_u08 FSL_Erase fsl_ul6 block_ul16 lt Assembler gt CALL _FSL_Erase or CALL _FSL_ Erase Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Erases FFH the content of the code flash memory in the specified block
82. not the frequency of the high speed on chip oscillator Note For the range of the maximum operating frequency of the CPU refer to the user s manual of the target RL78 microcontroller 12 Initialize the arguments RAM that are used by the flash self programming library functions When they are not initialized a RAM parity error is detected and the RL78 microcontroller might be reset For a RAM parity error refer to the user s manual of the target RL78 microcontroller 13 Writing to the code flash memory can be performed only to an area in the blank state or the area that has been erased It is impossible to rewrite overwrite to an area that has been written unless it has been erased When rewriting is performed without erasing data the code flash memory might be damaged 14 The R5F10266 product cannot use the flash self programming function 15 Some RL78 microcontrollers do not support an interrupt during the execution of flash self programming Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports an interrupt during the execution of the flash self programming 16 Some RL78 microcontrollers do not support the boot swap function Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports the boot swap function 17 Some RL78 microcontrollers do not support the security setting function by t
83. nterrupt destination change processing FSL_ChangelnterruptTable End interrupt destination change processing a cert ala Rev 1 03 RENESAS Page 65 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_BlankCheck Overview Blank checking of the specified block Format lt C language gt fsl_u08 FSL_BlankCheck fsl_ul6 block_ul16 lt Assembler gt CALL _FSL_BlankCheck or CALL _FSL_BlankCheck Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Checks that the code flash memory of the specified block is in the erasure level The erasure level check cannot be done in checking of FFH with data read In case of an error execute the FSL_Erase function If the execution of the FSL_Erase function is completed normally no blank checking is required If the specified block number does not exist a parameter error 05H is returned Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the
84. ny purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations It is the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 2012 4 General Precautions in the Handling of MPU MCU
85. o not set the specified RAM address to the area with usage restrictions during the execution of flash self programming The flash function may not operate normally The interrupt change destination cannot be set to the ROM side in the address range of FxxxxH When the interrupt destination is changed with this function the interrupt destination remains changed after flash self programming until the interrupt destination is restored with the FSL_RestorelnterruptTable function or a reset is performed When changing the interrupt destination to the RAM with this function prohibit interrupts from the start to end Register State After Call The register is not destructed RO1USO050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 62 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Argument Definition of argument EYA RAM address of the interrupt destination lower 16 bits FxxxxH Upper bits are not fsl_interrupt_destination_u16 required Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u16 fsl_interrupt_destination_u16 X 0 15 pee eee eee Eee The start address of the variable 16 bit RENESAS Large model fsl_u16 fsl_interrupt_destination_u16 X 0 15 ae eee The start address of the variable 16 bit Return Value None Operation Example Start interrupt destination chan
86. ode Remark For normal completion the return value cannot be checked FSL_SwapBootCluster PUSH PSW Flow Swap processing of the boot cluster NO End the flash environment Read the reset vector Jump to the registered address POP PSW of the reset vector a ae vie 03 Rev 1 03 RENESAS Page 86 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SwapActiveBootCluster Overview Inverting of the current value of the boot flag and execution of boot swapping Format lt C language gt fsl_u08 FSL_SwapActiveBootCluster void lt Assembler gt CALL _FSL_SwapActiveBootCluster or CALL _FSL_SwapActiveBootCluster Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function When this function is executed the current value of the boot flag is inverted and swapping of the boot clusters is executed Cautions 1 Do not execute this function in an RL78 microcontroller not supporting boot swapping 2 Before the execution of swapping always write the se
87. ootFlag FSL_SetBlockEraseProtectFlag FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow Register State After Call The register is not destructed Argument None Return Value None pee T Rev 1 03 RENESAS Page 61 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_ChangelnterruptTable Overview Changing of all interrupt destinations to the specified addresses on the RAM Format lt C language gt void FSL_ChangeInterruptTable fsl_ul fsl_interrupt_destination_ul6 lt Assembler gt CALL _FSL_ChangeInterruptTable or CALL _FSL_ChangeInterruptTable Remark Presetting None Function Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Changes the destinations of all the interrupt functions to the specified addresses on the RAM After the execution of this function when an interrupt occurs it enters the address on the RAM specified with this function without jumping to the interrupt table Cautions 1 The type of the interrupt must be determined by the user by checking the interrupt flag Because the type of the interrupt must be determined by the user after the execution of this function the interrupt flag will not be cleared automatically The user must perform clear processing after determining the type of the interrupt D
88. or omissions from the information included herein Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renes
89. orceReset FSL_GetVersionString Flash function idle state RO1USO0050EJ0103 Rev 1 03 Dec 22 2014 Waits until the processing is complete and makes a transition to the pause state Not available Makes a transition to the pause state RENESAS Page 51 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 6 6 List of Data Types Return Values and Return Types The data types are as follows Table 6 6 List of Data Types 1 byte 8 bit unsigned integer fsl_u16 2 byte 16 bit unsigned integer fsl_u32 unsigned long int 4 byte 32 bit unsigned integer The meaning of each return value is as follows Table 6 7 List of Return Values Definition Return Description value FSL_OK Normal completion FSL_ERR_PARAMETER 0x05 Parameter error acc aa The setting parameter has an error FSL_ERR_PROTECTION 0x10 Protect error The target area is protected FSL_ERR_ERASE Ox1A Erasure error ia Erasure of the target area failed FSL_ERR_BLANKCHECK 0x1B Blank check error The target area is not in the blank state FSL_ERR_IVERIFY Internal verification error An error occurred during internal verification processing of the target area FSL_ERR_WRITE 0x1C Writing error Writing to the target area failed FSL_ERR_FLOW Ox1F Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is v
90. ore the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Inverts the current value of the boot flag After a reset the boot cluster is in the state according to the boot flag setting Cautions 1 Do not execute this function in an RL78 microcontroller not supporting boot swapping 2 The boot cluster is not inverted upon the execution of the function 3 If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status check internal mode 2 Do not use interrupts or Set interrupts on the on chip ROM to protected until the processing of this function is complete the reception of interrupts on the RAM can be permitted Register State After Call Development tool Destructed register FS Oooo e S Argument None R01US0050EJ0103 Rev 1 03 Page 89 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x10 FSL_ERR_PROTECTION Protect error Changing of the flag from protected to permitted was tried Changing of the boot area switching flag was tried in the boot area rewrite protection state 0x1A FSL_ERR_ERASE Erasure error An error occurred during erasure processing 0x1B FSL_ERR_IVERIFY Internal verificatio
91. ormal completion Yi esy Reset Rewrite C Yes y Pre processing No Normal completion Yes y No FSL_IVerify f No Normal completion Yes la y Ending processing 4 v C End boot swapping gt RO1USO050EJ0103 Rev 1 03 Dec 22 2014 ztENESAS Page 36 of 109 RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 lt 1 gt Preprocessing Boot swap preprocessing Setting of the software environment reserving data buffer etc Initialization of flash self programming execution of the FSL_Init function Start of the flash environment execution of the FSL_Open function Preparation processing of the flash function execution of the FSL_PrepareFunctions function Preparation processing of the flash function extension function execution of the FSL_PrepareExtFunctions function RAM expansion processing of the ROMization code if the rewrite program is ROMized lt 2 gt Erasure of Boot Cluster 1 All the blocks contained in Boot Cluster 1 are erased by calling the FSL_Erase function Remark The FSL_Erase function performs erasure in units of blocks Normal operation mode Boot cluster 1 Boot cluster 1 Program area Program area Program area Boot Boot cluster 0 On chip debug security ID cluster 0 On chip debug securi
92. ot swap function replaces the boot program area Boot Cluster 0 Cluster 18 Before performing rewrite processing a new boot program is written to Boot Cluster 1 in advance Boot Cluster 1 and Boot Cluster 0 are swapped to make Boot Cluster 1 the boot program area As a result the program operates normally because booting is done from Boot Cluster 1 in the next reset start even when an instantaneous power interruption occurs during rewriting of the boot program area After that erasure or write processing to Boot Cluster 0 can be performed if necessary Note Boot Cluster 0 Boot program area Boot Cluster 1 Boot swap target area RO1USO050EJ0103 Rev 1 03 Page 35 of 109 Dec 22 2014 RENESAS RL78 Family Flash Self Programming Library Type 01 CHAPTER 5 BOOT SWAP FUNCTION 5 3 Boot Swapping Procedure Figure 5 1 shows an example of the flow of boot swapping using the flash self programming library lt 4 gt lt gt lt 10 gt lt 11 gt lt 12 gt lt 13 gt Figure 5 1 Example of Flow of Boot Swapping Start boot swap AA Pre processing v FSL_Erase v Normal completion Yes y No FSL Write y Normal completion Yi esy No FSL_IVerify i No Normal completion Yi esy FSL_GetSecurityFlags No Rewritable Yes y FSL_InvertBootFlag i No __ N
93. otFlag FSL_GetSwapState Not required FSL_GetBlockEndAddr FSL_GetFlashShieldWindow FSL_SwapBootCluster FSL_SwapActiveBootCluster FSL_InvertBootFlag FSL_SetBlockEraseProtectFlag Required FSL_SetWriteProtectFlag FSL_SetBootClusterProtectFlag FSL_SetFlashShieldWindow FSL_StatusCheck FSL_StandBy FSL_WakeUp Not required FSL_ForceReset FSL_GetVersionString Notes 1 The processing of this function does not require status checking because it is the function to perform status checking or functions to stop and restart the sequencer control during block erasure 2 To restart the block erasure processing FSL_Erase status checking is required to check the erasure state of the block a ae vie 03 Rev 1 03 RENESAS Page 47 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 6 4 1 Status Check User Mode In the status check User mode the back ground operatrion BGO can be performed on the RAM The lt R gt operation examples of each procedure is shown in the following figure Figure 6 2 Example 1 of Status Check User Mode FSL_Write When writing 12 bytes data User Library FSL_Write function executed Sequencer in operation Writing 4 bytes FSL_Write function closed Return value FSL_BUSY f Writing 4 bytes completed FSL_StatusCheck function executed FSL_StatusCheck function closed Return value FSL_BUSY Wri
94. pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 92 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_SetWriteProtectFlag Overview Setting of the write protection flag to protected Format lt C language gt fsl_u08 FSL_SetWriteProtectFlag void lt Assembler gt CALL _FSL_SetWriteProtectFlag or CALL _FSL_SetWriteProtectFlag Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received before the processing is complete use the FSL_ChangelnterruptTable function to change the interrupt destination to the RAM Function Sets the write protection flag to protected When it is set to protected writing to the device by the programmer cannot be done Caution If both of 1 and 2 are satisfied this function can be allocated on the on chip ROM for use 1 The specification of the status check mode in the FSL_Init function is set to the status
95. programmMing library ee eeeeeeeeeeeeeeeeeeeeeeeeeeaeeeseeaaeeeseeaaeeeseeaaeeeeeeaeeeeneaaes 29 20 2 5 Programi aloa sec ca fi cade erhes e Hace tees ee ee i eee ed ee ees 29 2 2 6 ROMization Of Programs cecccccceeceeeeeceeeeeeeeeeeeeaeeeeaee senses caeeeseaeeeeaeeseeeeesaeeesaeeeeneeee 29 2 3 Cautions on Programming Environment ccccccccceeeeeeeceeeeeeaeeeeeeeceaeeeeaaeseeaeeseeeeeseaeeeeaeeeeneeeea 30 CHAPTER 3 INTERRUPTS DURING EXECUTION OF FLASH SELF PROGRAMMING ae e cesta id pelt cet hed nde a Aaa a AREE A 32 S OVENI EW nimena hanana a a a a aa aa aa ai iaaa taaa aa 32 3 2 Interrupts During Execution of Flash Self Programming csscccceeeeeeeeeeeeneeseeeeeseeeeseaeeeeneeees 32 3 3 Cautions On MUSK rUPts onia i aa aacga a A a aA a E a AAA 33 CHAPTER 4 SECURITY SEIMNG 2 avaeAnaiaval Anas avar anal ana anata 34 4 Security Fla grire eet ative Re at ates Oe A a a ae at ac eet a elt 34 4 2 Flash Shield Window FUNCTION ccc ceceeeeeeeeeeeeeeeeeeeeceaeeeeaaeeeeeeeceaeeesaaeeeeaeeseeeeeseaeeesaeeeeneete 34 CHAPTER 5 BOOT SWAP FUNCTION ccceceeeeeeeeeeeeeeeeeeeeeeeeeeeeeneeeeeeeeeeeeneee 35 Be SWOVOIVIOW opran aa che tebe heed peters ed eel terest Ea aeae lees obs a a a OA a eth ee Daa A aA a i 35 52 Boot Swap FUNGUO Nateng hiiia tatea aaar aeaa aaan faea aiaa aaa aaa aa ice daguajeaeetasddedederbes 35 5 3 Boot Swapping Procedure cecccecccecececeeeeeeeeneeeeeeeec
96. pter 1 Overview p 5 The FSL_IVerify state check processing was added to Figure 2 2 a Chapter 2 Programming Environment p 14 A description of the case when flash functions are executed in the RAM was c added p 18 The formula for calculating the minimum time of FSL_BlankCheck was added a p 19 In Table 2 4 the formula for calculating the processing time for each function a was corrected p 24 The resources used to run the flash self programming library were corrected a p 24 In Table 2 7 the description of the self RAM area was changed c p 24 In note 1 on Table 2 7 the inquiry about device specifications was changed c p 25 The restriction on versions up to 2 10 was deleted from Figure 2 9 a p 26 A note was added to Table 2 8 Stack Size Used by Flash Functions c p 28 The description of the self RAM was reviewed and corrected c p 28 The available range for stack and data buffer specifications was corrected a p 30 In 3 the description of the functions that require special care regarding the c watchdog timer operation was reviewed and corrected P31 In 18 note on the prohibition of 64KB boundary arrangement added c Chapter 6 Flash Function 42 In Table 6 1 the column of basic functions added and position and description c ee of note was changed 48 and p49 The status check mode was corrected from the user mode to the internal c p p mode in table titles etc Remark Classification in the above tabl
97. ram area Boot cluster 0 pani On chip debug security ID cluster 0 setting area Option byte CALLT table _ Boot cluster 1 Boot cluster 1 lt 11 gt Writing of the new program to Boot Cluster 0 The content of the new program is written to Boot Cluster 0 by calling the FSL_Write function Boot Boot Alcea orazed cluster 0 eens cluster 0 Boot cluster 1 Boot cluster 1 RO1USO050EJ0103 Rev 1 03 Page 40 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 lt 12 gt Verification of Boot Cluster 0 All the blocks of Boot Cluster 0 to which writing has been done are verified by calling the FSL_IVerify function lt 13 gt End processing As the end processing of boot swapping the FSL_Close function is called 5 4 Cautions on Boot Swapping Boot swapping cannot be executed when the boot area Boot cluster 0 rewrite prohibition flag is set to 0 prohibited The flash functions providing the boot swap function have different cautions For details refer to CHAPTER 6 FLASH FUNCTIONS RO1USO050EJ0103 Rev 1 03 Page 41 of 109 Dec 22 2014 ztENESAS lt R gt RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 CHAPTER 6 FLASH FUNCTION This chapter describes the details of the flash functions functions in the flash self programming library 6 1 Type of Flash Functions The flash self programming
98. re some usage restrictions when they are allocated to the ROM FSL_BCD Area used by the FSL_PrepareFunctions function They can be allocated to the ROM or RAM FSL_BECD Area used by the FSL_PrepareExtFunctions function They can be allocated to the ROM or RAM a re T Rev 1 03 RENES AS Page 43 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Table 6 2 Segment List of Flash Functions Function name Segment name ROM allocation RAM allocation FSL_Init FSL_Open FSL_FCD FSL_Close FSL_FCD FSL_PrepareFunctions FSL_FCD FSL_BCD FSL_PrepareExtFunctions FSL_FCD FSL_BECD FSL_ChangelnterruptTable FSL_FCD FSL_RestorelnterruptTable FSL_FCD O FSL_GetSecurityFlags FSL_FECD O FSL_GetBootFlag FSL_FECD O ojojojolojojojojojo OJO FSL_GetSwapState FSL_FECD O FSL_GetBlockEndAddr FSL_FECD O Ojo FSL_GetFlashShieldWindow FSL_FECD O FSL_SwapActiveBootCluster FSL_RCD x FSL_InvertBootFlag FSL_RCD Ap FSL_SetBlockEraseProtectFlag FSL_RCD AN FSL_SetWriteProtectFlag FSL_RCD ane FSL_GetVersionString FSL_FCD O Ojojojo ojojojojojojojoio Note There are the following usage restrictions when they are allocated to the ROM Do not use the FSL_SwapActiveBootCluster function Set the specification of the status check mode to be set with the FSL_Init function to the status check internal mode a ae vie 03 Rev 1 03 RENESAS Page 44 of 109 RL78 Family Flash Self Programming Library Type
99. register C a ae vie 03 Rev 1 03 RENESAS Page 97 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 Argument Definition of argument near fsl_fsw_t setfsw_pstr FSW start and end block storage buffer Reserve a dedicated data buffer Definition of _ near fsl_fsw_t Development tool C language Assembly language Example of definition RENESAS typedef struct _setfsw_pstr fsl_u16 fsl_start_block_u16 _fsl_start_block_u16 fsl_u16 fsl_end_block_u16 _fsl_end_block_u16 fsl_fsw_t The content of __near fsl_fsw_t fsl_u16 fsl_start_block_u16 Start block of the flash shield window fsl_u16 fsl_end_block_u16 End block of the flash shield window Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model near fsl_fsw_t setfsw_pstr X 0 15 D eee The start address of the variable 16 bit RENESAS Large model near fsl_fsw_t setfsw_pstr X 0 15 a The start address of the variable 16 bit a cae ve 03 Rev 1 03 RENESAS Page 98 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x05 FSL_ERR_PARAMETER Parameter error The specification of the block number is outside the allowable setting range 0x1A FSL_ERR_ERASE Protect error The setting is protected 0x1B FSL_ERR_IVERIFY Erasure error
100. rogram area This is the area in which the flash self programming library and the user program using flash self programming library are allocated In flash self programming of the RL78 microcontroller the user program can be operated during rewriting of the code flash memory because the code flash memory is rewritten by using the sequencer background operation However the program allocated in the code flash memory cannot be referred to during rewriting of the code flash memory so some segments used by the user program and flash functions need to be allocated on the RAM depending on usage For details refer to the sections of CHAPTER 6 FLASH FUNCTION 2 2 6 ROMization of programs To allocate the user program and library using flash self programming on the RAM the target program must be ROMized and allocated to the code flash memory and the program must be expanded to the RAM before it is used in flash self programming For the ROMization function of the program allocated on the RAM refer to the user s manual attached to the development tool used inn oe aooo Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 3 Cautions on Programming Environment 1 lt R gt 3 Do not execute the EEPROM emulation library or data flash library during the execution of flash self programming When using the EEPROM emulation library or data flash library always execute FSL_Close
101. rror An error occurred during erasure processing 0x1B FSL_ERR_IVERIFY Internal verification error An error occurred during verification internal verification processing 0x1C FSL_ERR_WRITE Writing error An error occurred during write processing 0x1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state OxFF FSL_BUSY Execution start of this function The execution of this function has been started Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check internal mode 2 Only in the status check user mode a cae ve 03 Rev 1 03 RENESAS Page 88 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_InvertBootFlag Overview Inverting of the current value of the boot flag Format lt C language gt fsl_u08 FSL_InvertBootFlag void lt Assembler gt CALL _FSL_InvertBootFlag or CALL _FSL_InvertBootFlag Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareExtFunctions function must be completed normally Also when an interrupt must be received bef
102. s not support nested execution of functions If a flash function is executed within interrupt processing operation cannot be guaranteed When executing flash self programming on the operating system do not execute flash functions from multiple tasks The flash function does not support multiple executions of functions If a flash function is executed in multiple tasks operation cannot be guaranteed 10 Before starting flash self programming the high speed on chip oscillator needs to be started RO1US0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 30 of 109 RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 11 Note the following regarding the operating frequency of the CPU and the operating frequency value set with the initialization function FSL_Init When a frequency below 4 MHz is used as the operating frequency of the CPU 1 MHz 2 MHz or 3 MHz can be used a frequency such as 1 5 MHz that is not an integer value cannot be used Also set an integer value such as 1 2 or 3 as the operating frequency value set with the initialization function When 4 MHz or a higher frequency 4 is used as the operating frequency of the CPU a frequency with decimal places can be used However set a rounded up integer value as the operating frequency with the initialization function FSL_Init Example For 4 5 MHz set 5 with the initialization function This operating frequency is
103. sh function processing time differs depending on the status check mode This section shows the flash function processing time in the status check user mode Figure 2 5 Overview of Flash Self Programming Library Function Processing Time in Status Check User Mode FSL_Write FDL Status BUSY Function Processing Time FSL_StatusCheck Status BUSY FSL_StatusCheck Status BUSY FSL_StatusCheck Status OK RO1USO050EJ0103 Rev 1 03 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Table 2 1 Flash Function Processing Time in Status Check User Mode Full Speed Mode FSL_GetBlockEndAddr 368 fcLK FSL_GetFlashShieldWindow 307 fcLkK FSL_SwapBootCluster 419 fcLk 32 FSL_SwapActiveBootCluster 2316 fcLk 30 FSL_InvertBootFlag 2341 fcLK 30 FSL_SetBlockEraseProtectFlag 2347 fcLk 30 FSL_SetWriteProtectFlag 2346 fcLk 30 FSL_SetBootClusterProtectFlag 2347 fcLk 30 FSL_SetFlashShieldWindow FSL_StatusCheck 2141 fcLk 30 1135 fcLk 50 935 fcLk 31 Other than Erase 140367 fcLk 513844 FSL_StandBy when FSL_SetXXX are supported Other than Erase 76101 fcLk 35952 when FSL_SetXXX are not supported i Suspended Erase 2144 fcLk 30 FSL_WakeUp Other than Erase 148 fcLk FSL_ForceReset FSL_GetVersionString 10 fcLk Remark fck CPU operating frequency For example
104. supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited The reserved addresses are provided for the possible future expansion of functions Do not access these addresses the correct operation of LSI is not guaranteed if they are accessed 4 Clock Signals After applying a reset only release the reset line after the operating clock signal has become stable When switching the clock signal during program execution wait until the target clock signal has stabilized When the clock signal is generated with an external resonator or from an external oscillator during a reset ensure that the reset line is only released after full stabilization of the clock signal Moreover when switching to a clock signal produced with an external resonator or by an external oscillator while program execution is in progress wait until the target clock signal is stable 5 Differences between Products Before changing from one product to another i e to a product with a different part number confirm that the change will not lead to problems The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity layout pattern and other factors which can affect the ranges of electrical characteristics such as characteristic values operating margins immunity
105. t an interrupt during the execution of flash self programming Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports an interrupt during the execution of the flash self programming RO1USO050EJ0103 Rev 1 03 Page 33 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 4 SECURITY SETTING Flash Self Programming Library Type 01 CHAPTER 4 SECURITY SETTING The security function that prohibits rewriting of the user program written in the code flash memory is supported to prevent falsification of programs by a third party For details of security setting refer to the manual of the target device Note Some RL78 microcontrollers do not support the security setting function by the flash self programming Refer to the user s manual of the target RL78 microcontroller to see whether the RL78 microcontroller to be used supports the security setting function by the flash self programming 4 1 Security Flag The flash self programming library has the function to set the security flag for the details of the API of this function refer to CHAPTER 6 FLASH FUNCTION FSL_SetBlockEraseProtectFlag Sets the block erasure protection flag to Protected FSL_SetWriteProtectFlag Sets the write protection flag to Protected FSL_SetBootClusterProtectFlag Sets the boot area Boot cluster 0 rewrite protection flag to Protected 4 2 Flash Shield Window Function One of the security fu
106. tached to the installer or refer to the user s manual of the target RL78 microcontroller 2 For details of the flash memory programming mode refer to the user s manual of the target RL78 microcontroller 3 It is a required parameter for timing calculation in the flash self programming library This setting does not change the operating frequency of the RL78 microcontroller 4 For the range of the maximum operating frequency refer to the user s manual of the target RL78 microcontroller 5 When allocating the FSL_RCD segment on the ROM always use it in the status check internal mode Register State After Call Development tool Destructed register Renesas e d o O Argument Definition of argument __ far fsl_descriptor_t descriptor_pstr Initial setting value of the Flash Self Programming Library Type 01 flash memory programming mode CPU frequency status check mode Definition of __far fsl_descriptor_t Development tool C language Assembly language Example of definition RENESAS typedef struct _descriptor_pstr fsl_u08 fsl_flash_voltage_u08 _fsl_flash_voltage_u08 fsl_u08 fsl_frequency_u08 _fsl_frequency_u08 fsl_u08 fsl_auto_status_check_u08 fsl_auto_status_check_u08 fsl_descriptor_t The content of __ far fsl_descriptor_t fsl_flash_voltage_u08 Setting of the flash memory programming mode fsl_frequency_u08 CPU frequency during the execution of flash self programming fsl_
107. ted multiple times to complete all the writes to the specified block before a transition to the next processing Verification internal verification of the specified block 1 KB The FSL_IVerify function is called for verification internal verification of the specified block 1 KB Changing interrupt reception back to the ROM If the interrupt destination was changed to the RAM in lt 4 gt the FSL_RestorelnterruptTable function is called to change the interrupt reception destination back to the ROM Ending the flash environment The FSL_Close function is called to end flash self programming RO1US0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 7 of 109 RL78 Family CHAPTER1 OVERVIEW Flash Self Programming Library Type 01 lt 11 gt Status checking When the status check user mode is used status checking must be performed until the control of the code flash memory is finished Remark 1 word 4 bytes RO1US0050EJ0103 Rev 1 03 Page 8 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 CHAPTER 2 PROGRAMMING ENVIRONMENT This chapter describes the hardware environment and software environment required to rewrite the code flash memory using the flash self programming library 2 1 Hardware Environment Flash self programming of the RL78 microcontroller uses the sequencer to execute rewrite control of the flash memory During the control of the seq
108. tes are written the FSL_StatusCheck function must trigger the next write If the FSL_StatusCheck function is not executed while there are still bytes to be written the next write does not start and thus the write process does not end Figure 2 7 Overview of Interval for Checking Status When Using FSL_Write When Writing 12 Bytes FSL_Write FSL cope Write trigger Status BUSY i 4 byte write Call interval heck FSL_StatusChec mm Tet write ends Status BUSY Beas 4 byte write Call interval FSL_StatusCheck 2nd write ends Write trigger Status BUSY ey 4 byte write Call interval FSL_StatusCheck 83rd write ends Status OK RO1USO050EJ0103 Rev 1 03 Page 20 of 109 Dec 22 2014 ztENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 When a process is executed by a function other than FSL_Write in the status check user mode the sequencer is in the busy state until all processes end A trigger by the FSL_StatusCheck function is therefore not required Figure 2 8 Overview of Interval for Checking Status When Using a Function Other Than FSL_Write When Erasing Flash Memory Call interval RO1US0050EJ0103 Rev 1 03 Dec 22 2014 FSL_Erase Status BUSY No call for FSL_StatusCheck FSL_StatusCheck Status OK RENESAS eee Erase trigger 1 block erase Erase ends Page 21 of 109 RL78 F
109. ting trigger Sequencer in operation FSL_StatusCheck function executed Writing 4 bytes _ FSL_StatusCheck function closed For writing trigger processing with Return value FSL_BUSY FSL_StatusCheck is required for Writing 8 bytes completed every 4 bytes Executing FSL_StatusCheck before the completion of writing FSL_StatusCheck function executed i a with sequencer does not result in trigger processing FSL_StatusCheck function closed Writing trigger Return value FSL_BUSY Sequencer in operation Writing 4 bytes FSL_StatusCheck function executed Writing all 12 bytes completed cs FSL_StatusCheck function closed End of processing Return value FSL_OK RO1USO0050EJ0103 Rev 1 03 RENESAS Page 48 of 109 Dec 22 2014 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 lt R gt Figure 6 3 Example 2 of Status Check User Mode Other than FSL_Write User Library FSL_Erase function executed FSL_Erase function ended Return value FSL_BUSY FSL_StatusCheck Other processes can be function executed Sequencer executed because the function executing results are immediately returned FSL_StatusCheck However the status should be function ended verified until the functions are Return value executed FSL_BUSY FSL_StatusCheck function executed FSL_StatusCheck function ended Return value End of FSL_OK processing a cae ve 03 Rev 1 03 RENESAS Pa
110. tion of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally This function can be used only in the status check user mode Function Cancels the pause state and restarts flash self programming If block erasure processing is suspended it is restarted Register State After Call Development tool Destructed register Renesas de S o O Argument None R01US0050EJ0103 Rev 1 03 Page 104 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE 0x1F FSL_ERR_FLOW OxFF FSL_BUSY Erasure error An error occurred in the restarted erasure processing Flow error The prerequisite defined in presetting is violated Flash self programming is not in the pause state Note1 2 Restarting on the flash function The execution of the flash function was restarted Check the execution state with the FSL_StatusCheck function Notes 1 Only in the status check user mode 2 Only in restarting of erasure processing RO1USO0050EJ0103 Rev 1 03 Dec 22 2014 RENESAS Page 105 of 109 RL78 Family CHAPTER6 FLASH FUNCTION Flash Self Programming Library Type 01 FSL_ ForceReset Overview Resetting of the RL78 microcontroller in use Format lt C language gt void FSL_ForceReset void
111. to noise and amount of radiated noise When changing to a product with a different part number implement a system evaluation test for the given product HOW TO USE THIS MANUAL Readers This manual is intended for user engineers who wish to understand the functions of the RL78 microcontrollers Flash Self Programming Library Type 01 and design and develop application systems and programs for these devices Refer to the following list for the target MCUs Self Programming Library Japanese Release and Supported MCUs R20UT2861 XJUxxxx Purpose This manual is intended to give users an understanding of the methods described in the Organization below for using flash self programming library to rewrite the code flash memories Organization The RL78 Flash Self programming Library Type 01 user s manual is separated into the following parts e Overview e Programming Environment e Interrupts During Execution of Flash Self programming Security Setting e Boot Swap Function Flash Self Programming Function How to Read This Manual It is assumed that the readers of this manual have general knowledge of electrical engineering logic circuits and microcontrollers e To gain a general understanding of functions Read this manual in the order of the CONTENTS e To know details of the RL78 Microcontroller instructions Refer to CHAPTER 6 FLASH FUNCTION Conventions Data significance Higher digits on the left and lower digits o
112. to see whether the RL78 microcontroller to be used supports an interrupt during the execution of the flash self programming RO1US0050EJ0103 Rev 1 03 Page 9 of 109 Dec 22 2014 ztENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 e After an execution request of the desired processing is made to the sequencer of the RL78 microcontroller the control is immediately returned to the user program Because the sequencer controls the code flash memory the user program can be operated during the rewrite of the code flash memory This is called BGO background operation To use this mode select the status check user mode when initializing the Flash Self Programming Library Type 01 However the code flash memory cannot be referred to while the sequencer is controlling the code flash memory Therefore the user program that operates during code flash memory operation the branch destination of the interrupt the interrupt processing and some segments of the flash self programming library need to be allocated on the RAM For the result of the control of the code flash memory the status check function FSL_StatusCheck function must be called from the user program to check the control state of the code flash memory Figure 2 2 Example 1 Rewrite Control of Flash When User Program Operates during Rewrite User program Library Sequencer Execute On going Ret BUSY
113. tting information required for operation after swapping such as the option byte to the area of the swap destination 3 The boot clusters are swapped without a reset Do not allocate a user program data or flash self programming library required for rewriting in the boot cluster If it is required to refer to the program or data in the boot cluster after the execution of this function use it by considering that the boot clusters are swapped 4 This function cannot be executed from the ROM To use this function allocate the FSL_RCD segment on the RAM 5 After the execution of this function the interrupt vector on the ROM is also changed To use interrupt processing on the ROM before and after the execution use it by considering that the interrupt vector on the ROM switches during operation 6 If this function is used the functions contained in the FSL_RCD segment cannot be allocated on the ROM for use Register State After Call Development tool Destructed register RENESAS e o o O Argument None R01US0050EJ0103 Rev 1 03 Page 87 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x10 FSL_ERR_PROTECTION Protect error Changing of the flag from protected to be permitted was tried Changing of the boot area switching flag was tried in the boot area rewrite protection state 0x1A FSL_ERR_ERASE Erasure e
114. ty ID setting area setting area Option byte Option byte CALLT table CALLT table Vector table Vector table RO1US0050EJ0103 Rev 1 03 gt Page 37 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 5 BOOT SWAP FUNCTION Flash Self Programming Library Type 01 lt 3 gt Copying of the new boot program to Boot Cluster 1 A new boot program the program you want to allocate as the boot program area after boot swap processing is written to Boot Cluster 1 by calling the FSL_Write function Remark The FSL_Write function performs writing in units of words 1 word 4 bytes up to 64 words 256 bytes A new boot program is downloaded to the built in internal ROM via the external I F three wire SIO UART etc and written sequentially On chip RAM Boot ae J Boot rea erase cluster 1 7 cluster 1 Program area Program area Boot Boot cluster 0 On chip debug security ID cluster 0 On chip debug security ID setting area setting area Option byte Option byte CALLT table CALLT table Vector table Vector table lt 4 gt Verification of Boot Cluster 1 All the blocks of Boot Cluster 1 to which writing has been done are verified by calling the FSL_IVerify function Remark The FSL_IVerify function performs verification in units of blocks lt 5 gt Confirmation of the boot swap bit recommended The security flag information is obtained by calling the FSL_GetSecurityFlags function Check that the boot area Boot cluster
115. uencer the code flash memory cannot be referred to Therefore if the user program needs to be operated during sequencer control such as an interrupt some segments of the flash self programming library and the user program must be allocated in the RAM for control to perform erasure and writing to the code flash memory or setting of the security flag If it is not necessary to operate the user program during sequencer control the flash self programming library and user program can be allocated on the ROM for operation Figure 2 1 shows the state during a rewrite of the code flash memory Figure 2 2 and Figure 2 3 show examples of execution of flash functions to perform rewriting of the code flash memory Figure 2 1 State during Rewrite of Code Flash Memory Interrupts during code flash memory control can be handled only on the RAM Dedicated interrupt processing Internal RAM BGO background operation for the RAM is required in addition during code flash memory to interrupt processing for the control can be handled only ROM on the RAM Ye Internal ROM The inernal ROM cannot be referred to during code flash memory control interrupt reception cannot be done Normal vector interrupts cannot be received while code flash memory is being controlled Note Some RL78 microcontrollers do not support an interrupt during the execution of flash self programming Refer to the user s manual of the target RL78 microcontroller
116. using of flash self programming Format lt C language gt fsl_u08 FSL_StandBy lt Assembler gt CALL _FSL_StandBy or CALL _FSL_StandBy Remark Call with when the flash self programming library is allocated at OOOOOH OFFFFH or call with otherwise Presetting Before the execution of this function the FSL_Init function FSL_Open function and FSL_PrepareFunctions function must be completed normally This function can be used only in the status check user mode Function Suspends erasure processing FSL_Erase being executed and holds the erasure processing FSL_Erase in the pause state until FSL_WakeUp is executed When this function is executed flash self programming enters the pause state and flash self programming cannot be executed until FSL_WakeUp is executed Cautions 1 During a pause of flash self programming the flash functions cannot be executed To restart flash self programming the FSL_WakeUp function must be executed 2 A transition to the pause state occurs unless the return value is a flow error Register State After Call Development tool Destructed register RENESAS ea Se ee Se Argument None R01US0050EJ0103 Rev 1 03 Page 102 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_OK Normal completion 0x1A FSL_ERR_ERASE 0x1B FSL_ERR_BLANKCHECk 0x1B
117. uts the value to the data storage buffer specified in the argument Register State After Call Development tool Destructed register RENESAS a O Argument Definition of argument destination_pu08 Data storage buffer Reserve a dedicated data buffer Contents of argument settings Argument Type Register Development tool C language Assembly language RENESAS Small and medium model fsl_u08 destination_pu08 AX 0 15 The start address of the data buffer 16bit RENESAS Large model fsl_u08 destination_pu08 AX 0 15 ee eae The start address of the data buffer 16bit a cert aaa Rev 1 03 RENESAS Page 77 of 109 RL78 Family CHAPTER 6 FLASH FUNCTION Flash Self Programming Library Type 01 Return Value 0x00 FSL_Ok Normal completion 0Ox1F FSL_ERR_FLOW Flow error The processing of the flash function executed immediately before has not been completed The prerequisite defined in presetting is violated Flash self programming is in the pause state Note Only in the status check user mode Boot flag information The boot flag is written to the data storage buffer destination_pu16 passed in the argument Starts up with Boot Cluster 0 as the boot area QOOOH OFFFH after a reset Starts up with Boot Cluster 1 as the boot area QOOOH OFFFH after a reset Remark For the swap state of the boot area before the reset refer to the section on the FSL_GetSwapState function nea
118. ward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Ku Seoul 135 920 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2014 Renesas Electronics Corporation All rights reserved Colophon 3 0 RL78 Family 2rPENESAS Renesas Electronics Corporation RO1US0050EJ0103
119. when using a 20 MHz clock fctx is 20 RO1USO050EJ0103 Rev 1 03 Page 15 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 Table 2 2 Flash Function Processing Time in Status Check User Mode Wide Voltage Mode FSL_GetBlockEndAddr 368 fcLK FSL_GetFlashShieldWindow 307 fcLk FSL_SwapBootCluster 419 fcLk 32 FSL_SwapActiveBootCluster 2316 fcLk 30 FSL_InvertBootFlag 2341 fcLK 30 FSL_SetBlockEraseProtectFlag 2347 fcLk 30 FSL_SetWriteProtectFlag 2346 fcLk 30 FSL_SetBootClusterProtectFlag 2347 fcLk 30 FSL_SetFlashShieldWindow 2141 fcLk 30 FSL_StatusCheck 1135 fcLk 50 935 fcLk 44 Other than Erase 123274 fcLk 538046 FSL_StandBy when FSL_SetXXX are supported Other than Erase 73221 fcLk 69488 when FSL_SetXXX are not supported Suspended Erase 2144 fcLk 30 FSL_WakeUp Other than Erase 148 fcLk FSL_ForceReset FSL_GetVersionString 10 fcLk Remark fck CPU operating frequency For example when using a 20 MHz clock fck is 20 RO1USO050EJ0103 Rev 1 03 Page 16 of 109 Dec 22 2014 RENESAS RL78 Family CHAPTER 2 PROGRAMMING ENVIRONMENT Flash Self Programming Library Type 01 2 Flash self programming library function processing time in status check internal mode This section shows the flash function processing time in the status check internal mode Figure 2 6 Overview of Flash
Download Pdf Manuals
Related Search
Related Contents
Rapoo 1090P iGo 90W Automatic Laptop Wall Charger Mag-Bind® Tissue DNA Kit Mag-Bind® Tissue - Omega Bio-Tek Bedienungsanleitung Operating Instructions TLM 103 Embroidery of Athletic Uniforms - Purchasing MERIAN Vorbereitungsseminare MANUAL DE USUARIO PRECAUCIONES IMPORTANTES DE Nortel Networks DS30 User's Manual Downloaded from www.vandenborre.be Copyright © All rights reserved.
Failed to retrieve file