MC56f83783 programming and reading from flash not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MC56f83783 programming and reading from flash not working

2,375 次查看
zivn
Contributor I

Hi,

I'm trying to program and read from the Flash with no success. I'm using the fsl drivers:

fsl_flashiap.h

fsl_flashiap.c

from the project_template_mc56f83xxx

this is what I'm doing:

#define DATA_FLASH_START 0x20000
#define FLASH_SECTOR_SIZE 0x800

status_t fstatus;

uint8_t test_program_buffer[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };

uint8_t readresource_ifr[64];

flash_config_t sFlashConfig[] = {
{ 0 }
};

FLASH_Init(sFlashConfig);

fstatus = FLASH_Erase(sFlashConfig, DATA_FLASH_START, FLASH_SECTOR_SIZE, kFLASH_ApiEraseKey);
fstatus = FLASH_ProgramSection(sFlashConfig, (uint32_t)DATA_FLASH_START, (uint8_t *)test_program_buffer, (uint32_t)8);
fstatus = FLASH_ReadResource(sFlashConfig, (uint32_t)DATA_FLASH_START, (uint8_t *)readresource_ifr, (uint32_t)8, kFLASH_ResourceOptionFlashIfr);

I'm getting 0xFF on all the bytes in readresource_ifr[] which I expected to read back the programmed data bytes 

I imagine that the problem is that the bytes are not programmed into the Flash, but why  ?

Thanks

 

0 项奖励
回复
6 回复数

2,350 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

First of all,can you tell us the part number you are using? some Part number has only 128KB, some has 256KB.

Secondly, in the debugger, you can check if the flash contents are updated or not, you can display the memory from address P:0x1000, because you use byte address when you execute erasing/programming operation.

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复

2,348 次查看
zivn
Contributor I

Hi,

 

I'm using the MC56F83783VLH 

I believe this processor has 256K 

I have tried to look with the debugger both at address 0x10000 in word and and 0x20000 in byte and It's not showing that the flash is neither erased not programmed.

What address should I send to the erase operation and which address to the program if I want to access 0x20000 which is the first address of the second block ?

Thanks

 

0 项奖励
回复

2,336 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls try to use flashiap example in SDK package and check if there is any issue.

BR

XiangJun Rong

0 项奖励
回复

2,264 次查看
zivn
Contributor I

I managed to successfully write to the flash. I can program bytes in to address 0x20000, and then I can see the data in flash in address 0x10000 but only if I look at the address as program and not as data

zivn_0-1682362382734.png

 

My question is, how do I access this data from the code ?

I tried a few things but keep getting the wrong data:

uint8_t *fdata[8];

*fdata = (uint8_t *)(0x20000);

OR

uint32_t *fdata;

fdata = (uint32_t *)(0x20000);

I get the wrong data in fdata, although the address is 0x20000

zivn_1-1682363394628.png

How do I read the data from the flash correctly ?

0 项奖励
回复

2,255 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you want to read program flash, I suppose that there are two methods:

1)using the api function defined in the AN1952.pdf

https://www.nxp.com.cn/docs/en/application-note/AN1952.pdf

But the AN is based on DSP56800 core, now the MC56F83xxx uses DSP56800EX core, you have to modify the api function.

2)The program address in program domain is also mapped to data address in data domain, pls checked the data sheet and get the address in data domain.For example,

P:0x0_0000~0x1_FFFF is mapped to the data memory X:2_0000~3_FFFF, so you can read the X:3_0000 to get the data in P:0x1_0000.

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复

2,240 次查看
zivn
Contributor I

Thanks, this solved the problem

0 项奖励
回复