AnsweredAssumed Answered

How to read all of the contents from the 1Mb flash of mc9s12xep100,because it is 16 bit mcu,I only read 64kb space by this way *((u8 *)0x8000).but if I want to get the contents from the address 0x740000,I don't know how to do

Question asked by youdong sheng on Apr 25, 2017
Latest reply on Apr 27, 2017 by youdong sheng

I am writting the driver about flash of mc9s12xep100,I wrote some datas to the P-flash by the follow way,but I am not sure the datas had been wrote into the P-flash,NOW,I want to read them,I don't knom how to do.

void PFlash_Init()
{
while(FSTAT_CCIF==0); 
FCLKDIV=0x03; 
FCNFG=0x00; 
while(FCLKDIV_FDIVLD==0); 

}

 

void Erase_Pflash_block_2()
{

while(FSTAT_CCIF==0);

if(FSTAT_ACCERR) 
FSTAT_ACCERR=1;
if(FSTAT_FPVIOL) 
FSTAT_FPVIOL=1;

FCCOBIX=0x00;
FCCOB=0x0974; 
FCCOBIX=0x01;
FCCOB=0x0000;  
FSTAT_CCIF=1;
while(FSTAT_CCIF==0);
}

 

void Write_PFlash(u32 ADDR,u8 *data,u8 len)
{
u16 addr_H = 0;
u16 addr_L = 0;
u8 test_data[8] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};
u16 LS_data = 0;

addr_H = (ADDR >> 16) & 0xffff;
addr_L = ADDR & 0xffff;

if(len < 8)
return;

while(FSTAT_CCIF == 0);
if(FSTAT_ACCERR) 
FSTAT_ACCERR = 1;
if(FSTAT_FPVIOL)  
FSTAT_FPVIOL = 1;

FCCOBIX = 0x00;
FCCOB = 0x0600 | addr_H; 
FCCOBIX = 0x01; 
FCCOB = addr_L;

LS_data = test_data[1];
LS_data = (LS_data << 8) | test_data[0];
FCCOBIX = 0x02; 
FCCOB = 0x1221;

LS_data = test_data[3];
LS_data = (LS_data << 8) | test_data[2];
FCCOBIX = 0x03; //写入第二个数据
FCCOB = 0x1331;

LS_data = test_data[5];
LS_data = (LS_data << 8) | test_data[4];
FCCOBIX = 0x04; //写入第三个数据
FCCOB = 0x1441;

LS_data = test_data[7];
LS_data = (LS_data << 8) | test_data[6];
FCCOBIX = 0x05; //写入第四个数据
FCCOB = 0x1551;

FSTAT_CCIF = 1; //写入执行命令
while(FSTAT_CCIF == 0); //等待执行完毕
}

Outcomes