在线时间10 小时
UID3073835
注册时间2014-11-25
NXP金币15
该用户从未签到
注册会员

- 积分
- 172
- 最后登录
- 2017-8-11
|
请教大侠:
我的CPU型号是MK10DX256VLL7, 使用CW10.6开发环境, 通过PE将32K的D-FLASH分区为D-FLASH和EEROM, 如下图:
使用EPROM的代码为网站上的案例, 略作修改如下, 我的问题:
1. 虽然已经用PE划分了EEPROM分区,但CW调试时,partition_flash()返回1, 说明PE没有分区成功.
2. 而且, 再次CW调试进入,还是返回1, 说明用partition_flash()也没有分区成功。
哪位大侠指点一下?
#define EEPROMBASEADDRESS_M 0x14000000
#define EEPROM_512_512 0x34 // subsystem A = 512 bytes, subsystem B = 512 bytes
#define DFLASH_SIZE_24 0x09 /* Defines for the dflash_size parameter */
int partition_flash(int eeprom_size, int dflash_size)
{
/* Test to make sure the device is not already partitioned. If it
* is already partitioned, then return with no action performed.
*/
if ((SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00)
{
return 0;
}
/* Write the FCCOB registers */
FTFL_FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFL_FCCOB1 = 0x00;
FTFL_FCCOB2 = 0x00;
FTFL_FCCOB3 = 0x00;
/* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
FTFL_FCCOB4 = eeprom_size;
/* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
FTFL_FCCOB5 = dflash_size;
/* All required FCCOBx registers are written, so launch the command */
FTFL_FSTAT = FTFL_FSTAT_CCIF_MASK;
/* Wait for the command to complete */
while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK));
return 1;
}
unsigned char WRITE(unsigned long *pEEPAddr,unsigned long *pRamAddr,unsigned short int num)
{
unsigned long *pusDstAddr = (unsigned long *)((unsigned long)pEEPAddr + EEPROMBASEADDRESS_M);
unsigned long *pusSrcAddr = (unsigned long *)pRamAddr;
unsigned short i;
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
for(i=0;i<num/4;i++)
{
*((unsigned long*)(pusDstAddr)) = *((unsigned long*)(pusSrcAddr));
pusDstAddr = pusDstAddr + 1;
pusSrcAddr = pusSrcAddr+ 1;
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
}
return 0;
}
unsigned char READ(unsigned long *pEEPAddr,unsigned long *pRamAddr,unsigned short num)
{
unsigned long *pusDstAddr = (unsigned long *)pEEPAddr;
unsigned long *pusSrcAddr = (unsigned long *)pRamAddr;
unsigned short i;
for(i=0; i<num/4;i++)
{
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
*((unsigned long*)(pusSrcAddr)) = *((unsigned long*)(pusDstAddr));
pusDstAddr = pusDstAddr + 1;
pusSrcAddr = pusSrcAddr + 1;
}
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
return OK;
}
unsigned char ConfigPara[32];
void InterFlashTest()
{
unsigned long *pulPara = (unsigned long *)ConfigPara;
unsigned char i;
BYTE result;
partition_flash(EEPROM_512_512,DFLASH_SIZE_24);
if ( 0 == READ((unsigned long *)0x14000000, pulPara, 32))
{
memset((void *)ConfigPara, 0x55, 32);
WRITE((unsigned long)0x0, pulPara, 32);
}
}
}
|
|