Reading flash - why not by normal memory access?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading flash - why not by normal memory access?

Jump to solution
1,283 Views
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

Labels (1)
0 Kudos
Reply
1 Solution
838 Views
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

View solution in original post

0 Kudos
Reply
2 Replies
838 Views
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 Kudos
Reply
839 Views
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 Kudos
Reply