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.
9 years, 7 months ago.
Write memory
Hi! I`m starting with the kl46z and I wanted to save values into the flash memory. I wanted to know if there is a easy way to do it.
thanks
Assigned to
9 years, 7 months ago.This means that the question has been accepted and is being worked on.
You assigned the question to yourself, so no one can answer.
Writing flash on Freescale platforms can be done with: https://mbed.org/users/Sissors/code/FreescaleIAP/. Things to take into account is that flash always need to be erased per sector (sector size on your target is 1024 bytes, which is fairly small, but still large), and that flash has limitted write endurance: If you want to save for example some user settings in flash that is perfectly fine. If you want to save the current temperature every second in flash, then your flash won't have a very long lifespan.
posted by Erik - 10 Sep 2014Sorry I`m new on this. I`m working with your library now. Thanks Erik
posted by Fernanda Suarez 10 Sep 2014Hi again, i`m trying with your library and this program. but when i want to compile, the following error appear
Error: Undefined symbol flash_size() (referred from FreescaleIAP.cpp.KL46Z.o). Error: Undefined symbol erase_sector(int) (referred from FreescaleIAP.cpp.KL46Z.o). Error: Undefined symbol program_flash(int, char*, unsigned) (referred from FreescaleIAP.cpp.KL46Z.o).
int main() { int address = flash_size() - SECTOR_SIZE; Write in last sector
int *data = (int*)address; printf("Starting\r\n"); erase_sector(address); int numbers[10] = {0, 1, 10, 100, 1000, 10000, 1000000, 10000000, 100000000, 1000000000}; program_flash(address, (char*)&numbers, 40); 10 integers of 4 bytes each: 40 bytes length printf("Resulting flash: \r\n"); for (int i = 0; i<10; i++) printf("%d\r\n", data[i]);
printf("Done\r\n\n");
while (true) { } }
posted by Fernanda Suarez 19 Sep 2014