Reading flash - why not by normal memory access?

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

Reading flash - why not by normal memory access?

跳至解决方案
1,091 次查看
l0wside
Contributor II

While porting an application from TI´s MSP430 to the Kinetis KL15, I came to the point of porting the flash access routines. I am placing my configuration data in flash, this is working fine on the MSP430.

I am used to (read) access the flash memory like I would access data in RAM. As the Kinetis has a von Neumann Architecture (i.e. single memory area for both program and data memory), I had expected the same to be true for the Kinetis. However, what PE generates does not quite look like a simple memory access.

It was really convenient to use flash memory like RAM when reading, I am not exactly eager to copy everything into RAM before being able to use it. It means extra code and extra RAM. Is there a chance to access some user flash area with a simple read access? If yes, how? If not, what is the problem?

Max

标签 (1)
0 项奖励
回复
1 解答
646 次查看
mjbcswitzerland
Specialist V

Max

You can read data from the program flash as any memory-mapped address so there is no need to use special routines.

You only need Flash functions when deleting or programming.

If the code that you have is using flash routines for reading it is either the wrong code or something is incorrectly configured.

If your configuration data is in declared as a const array or struct you can simpy access it as any variable. Otherwise any pointer access to the Flash location can be used (eg. ucValue = *(unsigned char *)*0x2000;)

Regards

Mark

在原帖中查看解决方案

0 项奖励
回复
2 回复数
646 次查看
l0wside
Contributor II

Mark,

thank you. I was on the wrong track after looking into the help of PE, which has the function

  • GetBlockFlash - Reads data from FLASH.
    ANSIC prototype:
      • byte GetBlockFlash(
    ComponentName_
      • TAddress Source,
    ComponentName_
      • TDataAddress Dest, word Count)
    • Source:ComponentName_TAddress - Destination address in FLASH.
    • Dest:ComponentName_TDataAddress - Source address of the data.
    • Count:word - Count of the data fields (in the smallest addressable units).
    • Return value:byte - Error code, possible codes:
      • ERR_OK - OK
      • ERR_NOTAVAIL - Desired program/erase operation is not available
      • ERR_RANGE - The address is out of range
      • ERR_BUSY - Device is busy

I had supposed there is a reason for this function - but it does not seem so.

Max

0 项奖励
回复
647 次查看
mjbcswitzerland
Specialist V

Max

You can read data from the program flash as any memory-mapped address so there is no need to use special routines.

You only need Flash functions when deleting or programming.

If the code that you have is using flash routines for reading it is either the wrong code or something is incorrectly configured.

If your configuration data is in declared as a const array or struct you can simpy access it as any variable. Otherwise any pointer access to the Flash location can be used (eg. ucValue = *(unsigned char *)*0x2000;)

Regards

Mark

0 项奖励
回复