目录
瑞萨RH850 Flash中有两种存储类型:Mapping of Code Flash Memory和Mapping of Data Flash Memory。
Mapping of Code Flash Memory存储代码,Mapping of Data Flash Memory存储数据。
瑞萨车规级MCU操作Flash没有直接提供寄存器接口,需要安装官方提供的库文件,有三种形式:
RH850 FCL、FDL和EEL安装包、源码、配置PPT和使用说明-嵌入式文档类资源
对汽车电子技术、瑞萨MCU感兴趣的小伙伴请关注公众号:美男子玩编程,公众号优先推送最新技术博文,创作不易,请各位朋友多多点赞、收藏、关注支持~
第1步:下载FCL库。
FCL库官网地址:Code Flash Libraries (Flash Self Programming Libraries)
RH850 FCL库与用户手册地址:RH850/F1KM-S4 Design Support Resources | Renesas
第2步:安装FCL库。
安装完成后可见官方库文件和用户使用文件两部分:
文件系统结构说明如下所示:
第3步:将官方库文件和对应的用户使用文件添加到自己的工程后,在CS+工程中的添加FCL需要的代码段,如下图所示:
注意:
/* This array reserves the copy area in the device RAM */
#define FCL_RAM_EXECUTION_AREA_SIZE 0x8000
R_FCL_NOINIT uint8_t FCL_Copy_area[FCL_RAM_EXECUTION_AREA_SIZE];
W0561322:Section alignment mismatch : "R_FCL_CODE_USR.text"
W0561322:Section alignment mismatch : "R_FCL_CODE_RAM.text"
W0561322:Section alignment mismatch : "R_FCL_CODE_ROMRAM.text"
第4步:修改fcl_cfg.h文件。
#define R_FCL_COMMAND_EXECUTION_MODE R_FCL_HANDLER_CALL_USER
//修改成
#define R_FCL_COMMAND_EXECUTION_MODE R_FCL_HANDLER_CALL_INTERNAL
第5步: 修改fcl_descriptor.h文件。
#define FCL_CPU_FREQUENCY_MHZ (240) /*!< CPU frequency in MHz */
#define FCL_AUTHENTICATION_ID {0xFFFFFFFF, \
0xFFFFFFFF, \
0xFFFFFFFF, \
0xFFFFFFFF} /*!< 128Bit authentication ID */
#define FCL_RAM_ADDRESS 0xFEBC0000 /*!< RAM address range blocked for FCL */
第6步:修改r_fcl_types.h文件。
#define R_FCL_NO_BFA_SWITCH
#if ((defined R_FCL_MIRROR_FCU_COPY) && (defined R_FCL_NO_FCU_COPY))
#error "r_fcl_types.h: Invalid define for support device macro"
#elif ((defined R_FCL_MIRROR_FCU_COPY) && (defined R_FCL_NO_BFA_SWITCH))
#error "r_fcl_types.h: Invalid define for support device macro"
#elif ((defined R_FCL_NO_FCU_COPY) && (defined R_FCL_NO_BFA_SWITCH))
#error "r_fcl_types.h: Invalid define for support device macro"
#elif (defined R_FCL_MIRROR_FCU_COPY)
#define R_FCL_INNER_NO_BFA_SWITCH
#elif (defined R_FCL_NO_FCU_COPY)
#define R_FCL_INNER_NO_FCU_COPY
#elif (defined R_FCL_NO_BFA_SWITCH)
#define R_FCL_INNER_NO_BFA_SWITCH
#define R_FCL_INNER_NO_FCU_COPY
#endif
在FCL V2.12版本中增加了R_FCL_NO_FCU_COPY、R_FCL_MIRROR_FCU_COPY和R_FCL_NO_BFA_SWITCH预编译配置选项。
预编译目标设备所需的定义如下表所示:
第1步:下载FDL库。
FDL库官网地址:Data Flash Libraries
RH850 FDL库与用户手册地址:RH850/F1KM-S4 Design Support Resources
第2步:安装FDL库。
安装完成后可见官方库文件和用户使用文件两部分:
第3步:将官方库文件和对应的用户使用文件添加到自己的工程后,在CS+工程中的添加FDL需要的代码段,如下图所示:
注意:
第4步:修改r_fdl.h文件。
#define R_FDL_NO_BFA_SWITCH
/* Global compiler definition */
#if ((defined R_FDL_MIRROR_FCU_COPY) && (defined R_FDL_NO_FCU_COPY))
#error "r_fdl.h: Invalid define for support device macro"
#elif ((defined R_FDL_MIRROR_FCU_COPY) && (defined R_FDL_NO_BFA_SWITCH))
#error "r_fdl.h: Invalid define for support device macro"
#elif ((defined R_FDL_NO_FCU_COPY) && (defined R_FDL_NO_BFA_SWITCH))
#error "r_fdl.h: Invalid define for support device macro"
#elif (defined R_FDL_MIRROR_FCU_COPY)
#define R_FDL_INNER_NO_BFA_SWITCH
#elif (defined R_FDL_NO_FCU_COPY)
#define R_FDL_INNER_NO_FCU_COPY
#elif (defined R_FDL_NO_BFA_SWITCH)
#define R_FDL_INNER_NO_BFA_SWITCH
#define R_FDL_INNER_NO_FCU_COPY
#endif
预编译目标设备所需的定义如下表所示:
第5步:修改fdl_descriptor.h文件。
/* The Flash programming hardware is provided with a clock, derived from the CPU subsystem frequency. Check that
the frequency is correct as this has an impact on the programming quality and performance! */
#define CPU_FREQUENCY_MHZ (240) /**< CPU frequency in MHz */
/*****************************************************************************************************************
* Important definitions for run-time configuration of the FDL:
* - EEL/FDL Pool -
*****************************************************************************************************************/
/* The physical erase unit of the Data Flash is 64Byte.
The Renesas EEL works with a ring buffer consisting of ring buffer (virtual) blocks that merge a certain number
of physical blocks.
E.g. virtual block size of 2kB equals 32 physical blocks of 64Bytes --> EEL_VIRTUALBLOCKSIZE = 32
virtual block size of 4kB equals 64 physical blocks of 64Bytes --> EEL_VIRTUALBLOCKSIZE = 64
Note: If the Renesas EEL is not used, an alignment is not necessary "EEL_VIRTUALBLOCKSIZE" need not be defined
and the pools start and size definitions can be set free to the application needs */
#define EEL_VIRTUALBLOCKSIZE (64u)
#define FDL_POOL_SIZE (16u * EEL_VIRTUALBLOCKSIZE) /**< Number of Data Flash blocks, accessible by
the FDL. Typically it is the complete
no. of available Data Flash blocks */
#define EEL_POOL_START (1u * EEL_VIRTUALBLOCKSIZE) /**< 1st block of the EEL pool */
#define EEL_POOL_SIZE (6u * EEL_VIRTUALBLOCKSIZE) /**< no. of blocks for the EEL pool */
FDL和EEL都是操作Data Flash Memory,EEL依托于FDL,在FDL库中已经讲解了使用EEL的方法。EEL和FDL关系如下图所示:
RH850FCL、FDL和EEL安装包、源码、配置PPT和使用说明-嵌入式文档类资源