Hi,
i am using board which contains NXP's lpc54102. I am trying to write data to a flash (Sector 15 , Address 0x0007E000) and read it using memcpy() function. I am using Chip_IAP_CopyRamToFlash() api to write data. If i read data using memcpy() immediately after writing then i am able to read the proper data. if i try to read data in some other file using memcpy function, then i am not getting the expected data. What could be the issue? Is there any sequence to follow while reading data from the flash?(IAP mode)
Thanks in adavance,
Ck
解決済! 解決策の投稿を見る。
In earlier post you mentioned like this.
" Where is the code running that is trying to write to the flash? It MUST be (re)located in RAM - you cannot program the flash if the code is running from that flash"
Now i got doubt where exactly my code will reside? Is it on RAM or flash? By default program gets stored in flash right? Do i need to move IAP wrapper code to RAM? If so, how to do it?
Second thing, Once i write data to the Flash using IAP command then it should be there in flash. Now in my case i am using sector 15 ( address 0x00078000). And i should be able to read the data anytime right (after power cycle also)?.
So if the correct values are stored in the flash, then it must be a bug in your code that is reading the wrong values... Use the debugger to find out what addresses you are using in your memcpy and also check the ode that validates the values.
So if the correct values are stored in the flash, then it must be a bug in your code that is reading the wrong values... Use the debugger to find out what addresses you are using in your memcpy and also check the ode that validates the values.
After writing to the flash using copyRAMtoFlash() command i read the data using memcpy() function and i colud see the data which i have written to the flash. After program comes out of that function when i try to read data using memcpy() from the sdame address then i am not getting the expected result.
Thanks,
Chethan
If you are using LPCXpresso (as I am) this FAQ describes how to place code into RAM: Relocating code from FLASH to RAM
After writing to the flash using copyRAMtoFlash() command i read the data using memcpy() function and i colud see the data which i have written to the flash. After program comes out of that function when i try to read data using memcpy() from the sdame address then i am not getting the expected result.
This suggests that your 1st memcpy() is not actually copying from flash - perhaps your are checking your original ram-based data? As I said, you should use a debugger to actually check that you are really doing what you think you are doing (i.e. checking the addresses used in the various memcpy() calls).
Issue resolved. Issue was with my code
Thanks.
I would guess that the write never worked. Where is the code running that is trying to write to the flash? It MUST be (re)located in RAM - you cannot program the flash if the code is running from that flash.
Hi,
Write function worked. I tested and verified by reading the data from flash
using memcpy function. I am able to see the correct data in one particular
file. When I try to read data using memcpy in some other file then I am
not seeing the same data which I saw in another file.
Code to write to flash is there in RAM itself.
Thanks,
Chethan
So if the correct values are stored in the flash, then it must be a bug in your code that is reading the wrong values... Use the debugger to find out what addresses you are using in your memcpy and also check the ode that validates the values.