hello kerryzhou
i am currently working on flash_demo project given in kinetis KSDK 1.3.0.
in this demo there are function for flash_program and flash_program_check i understand that function and apply in my project now i need a slimiler function for flah_read from any location of flash.
please suggest me some solution regarding flash_read.
Thanks And Best Regards,
Arth Shah
Solved! Go to Solution.
Hi Arth
unsigned long flash_add = *(unsigned long *)0x00005420;
This is valid code and when I try to build with VisualStudio or with GCC there are no errors or warnings. Please check exactly how you have written it.
unsigned char ucBuffer[100];
memcpy(ucBuffer, (void *)0x00005420, sizeof(ucBuffer));
This will copy 100 bytes stating from the Flash address 0x5420 to the buffer.
Regards
Mark
Arth
Flash is memory mapped so you can read with
TYPE value = *(TYPE *)flash_address; // where TYPE is unsigned char, unsigned long etc.
To read a block, just use memcpy().
eg.
unsigned char ucBuffer[100];
memcpy(ucBuffer, flash_address, 100);
Regards
Mark
hello Mark,
Thanks for reply.
i want to read data from 0x00005420 memory location.
please give me example on that.
when i write unsigned long flash_add=*(unsigned long*)0x00005420
it give me error like
"initializer element is not constant "
and other question is that when i give starting address of memory then we get 100 data from that to our ucBuffer?
thanks
Hi Arth
unsigned long flash_add = *(unsigned long *)0x00005420;
This is valid code and when I try to build with VisualStudio or with GCC there are no errors or warnings. Please check exactly how you have written it.
unsigned char ucBuffer[100];
memcpy(ucBuffer, (void *)0x00005420, sizeof(ucBuffer));
This will copy 100 bytes stating from the Flash address 0x5420 to the buffer.
Regards
Mark
Hello Mark,
Thanks for help.. I don't know why this declaration is not work for my KDS.but i understand what you said .
Thanks for reply..!!
Arth
KDS uses GCC. In KDS I don't get any problems. Strange...
Regards
Mark