Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 6 months ago.
How to read data from the flash
After reviewing the IAP internal flash write example and documentation, I seem to be missing a basic point:
How do I read the contents of the flash into memory?
In my application I want to store a large data table in flash (only once or maybe occasional updates) but refer to the table frequently and rapidly. In the example and in the hardware manual I see write and compare, but not a simple read function.
I'm sure I must be missing something basic.
Thanks,
Chuck
Question relating to:
1 Answer
10 years, 6 months ago.
See in the main.cpp there the memdump function. The basic part you are missing is that you need specialised hardware to write to the flash (I personally don't know why you would want to use that hardware also for comparing, since you can simply read it out and compare it in code), but you don't need anything special to read from flash, you do it all the time in your code.
What you only need to know is the address where it is stored, which depends on which flash block you are using. Then you can simply make a pointer towards that block. For example:
char *table = (char*)your_address;
Make a new table pointer (effectively the same as an array, so afterwards you can use it as an array), and give that as value the address where the data is, converted to char pointer.
Since editting answers seems to be again/still broken, you can also check as example: http://mbed.org/users/Sissors/code/FreescaleIAP/. It is for Freescale devices, and uses significantly different functions, but it also uses that method to read back data.
posted by 20 Jun 2014