How to read data from internal flash by using C90TFS library

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to read data from internal flash by using C90TFS library

ソリューションへジャンプ
1,710件の閲覧回数
alexshephard
Contributor I

I am trying to read data from Pflash and Dflash from MK20DX256 by using C90TFS library in KSDK 1.3.

But I cannot find read function in the library. Then how do you guys read data from the flash?

ラベル(1)
0 件の賞賛
返信
1 解決策
941件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alex,

Regarding your question, as you know that the ARM architecture uses the normalized address space for the program/data flash, SRAM and peripheral, special commands are required to erase/program flash, but you can read a flash address as you read a RAM address.

you can read flash or RAM using the following macro based on the data width you access.

#define READ8(address)              ((uint8_t)(*(vuint8_t*)(address)))
#define READ16(address)             ((uint16_t)(*(vuint16_t*)(address)))
#define READ32(address)             ((uint32_t)(*(vuint32_t*)(address)))

for example, you can use the following code to access flash no matter whether the flash save data or code.

uint16_t value, i, *pSrc, *pDest;

pSrc=0xxxxxxxx;

value=READ16(pSrc);

pSrc++;

BR

XiangJun Rong

元の投稿で解決策を見る

2 返答(返信)
942件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alex,

Regarding your question, as you know that the ARM architecture uses the normalized address space for the program/data flash, SRAM and peripheral, special commands are required to erase/program flash, but you can read a flash address as you read a RAM address.

you can read flash or RAM using the following macro based on the data width you access.

#define READ8(address)              ((uint8_t)(*(vuint8_t*)(address)))
#define READ16(address)             ((uint16_t)(*(vuint16_t*)(address)))
#define READ32(address)             ((uint32_t)(*(vuint32_t*)(address)))

for example, you can use the following code to access flash no matter whether the flash save data or code.

uint16_t value, i, *pSrc, *pDest;

pSrc=0xxxxxxxx;

value=READ16(pSrc);

pSrc++;

BR

XiangJun Rong

941件の閲覧回数
calebrust
Contributor III

I was trying for several hours to read program flash using the FlashReadResource() function.  After reading this post I tried the READ32() macro, and it just worked.  Yay!

Sidenote:

It's strange to me that the C90TFS library has 2 functions to read the P-Flash IFR(FlashReadResource, and ReadOnce), but neither can read the basic program flash.  If you try to pass in an absolute address, e.g. 0x7E000 for a 512KB MKW2x chip, the FlashReadResource function will return an access error (ACCERR).  After lots of reading I realized that the access error is because these functions are only supposed to access IFR memory (see Table 35-44 of the MKW2x reference manual for valid local address ranges). 

Thanks for the info XiangJun Rong!

0 件の賞賛
返信