Hai all;
I am working for an automotive project using LPC 2368.Here I want to store data from RAM to 512k FLASH and to read back while program is running.
I wrote some programs such as IAP for LPC2129 and Flash programming from C:\Keil\ARM\FLASH\LPC_IAP2_512.
In both cases while writing data to Flash from RAM(I wrote some values to RAM),the data in FLASH remain zeros,but in a RED colour.
Will you please tell me ,What is the reason behind this.
Sincerely shamsudheen OP
how do you test your code?
Dear sir;
I am really sorry for not giving how I tested the code. I took the code from C:\Keil\ARM\FLASH\LPC_IAP2_512 in uVision3 and my main program given below.
main() { unsigned char buf[512]; //RAM memory(source) unsigned char *flashdata; //Reading back to RAM int i;
/*writing data to RAM */
for (i = 0; i < sizeof (buf); i++) { buf[i] = (unsigned char) i; }
/* * Initialize Flash Programming Functions * Parameter: 0x00058000: Device Base Address * 4000000 : Clock Frequency (Hz) * 2 : Function Code (2 - Program) * Return Value: 0 - OK, 1 - Failed */
Init(0x00058000,4000000,2);
/* * Program Page in Flash Memory * Parameter: 0x00058000: Page Start Address * 512: Page Size * buf: Page Data * Return Value: 0 - OK, 1 - Failed */
ProgramPage(0x00058000, 512 , buf);
/*Reading back to RAM*/
flashdata = (unsigned char *)0x00058000;
}
Here I am writing data at RAM location 0x40000278. It is working fine.After copying form RAM at(0x40000278) to FLASH at 0x00058000,the flash data remain zeros,but which is in red in colour.
Here all function returning zeros indicating that working fine.
Here Erase function also working fine,I can Erase these flash data(0x00) to 0xFF.
Will you please tell me ,why i can't copy data from RAM to FLASH effectively.
Sincerely shamsuheen OP
Do you run this software on real target hardware or under the simulator?
The simulator does not simulate the IAP programming.
Simulator does simulate the IAP for the complete LPC devices.
Example Keil\ARM\ARM\Boards\Keil\MCB2100\IAP runs in target and simulator. It is however for the LPC2100 devices and needs to be modified for the LPC23xx (different startup file and Flash Sector Layout).
sorry,this code is working fine in uVision3 simulator after adding "EraseSector (0x00058000)" after initialization.Code is shown below. Here I am writing some data from RAM (0x4000026c) to FLASH at (0x00058000) and I restore data from FLASH(0x00058000) to RAM at (0x4000006c) .
But when I downloaded to target (MCB2300) it is not showing any kind of output.
I saw that , While debugging when the ULINK2 is connected to my Computer,It is showing an error like this;
Memory mismatch:
Address:0x00000000 Value=0x40 Expected=0x40
Will you please tell me what is the error behind this.
I took the code from C:\Keil\ARM\FLASH\LPC_IAP2_512 in uVision3 and my main program given below.
main() { unsigned char buf[512]="sajna\n"; //RAM memory(source)
unsigned char DESTbuf[512]; //Reading back to RAM int i;
/*Erasing sector starting from 0x00058000*/
EraseSector (0x00058000);
for(i=0; i< sizeof(DESTbuf) ; i++) {
DESTbuf[i]=*((unsigned char *)0x00058000+i); }
I have created a test project based on Keil\ARM\Flash\LPC_IAP2_512 (selected the correct chip, setup the target memory and linker settings, added a startup, removed the FlashDev.c) and added your test code.
The program runs as expected on my MCB2300 with LPC2378 (and should work also on LPC2368 which has the same Flash).
I guess that you have missed something when you have created you test project.
All the code expect the following code is working in MCB2300 board.Here I am using the selected flash sector as a storage device(Like EEPROM).That is , I want to write some data to selected Flash Sector and read back to some other RAM location as above in the program while my program is running.
In simulator I can read data from flash to RAM using same code below , but in target it is not working.If I am putting following code in program it is not working in Target(MCB2300) .That is , I canot read the data back to RAM.
/*Reading From flash to RAM*/
Will be there any other reading mechanism from FLASH to RAM.
We having a function for copying RAM to FLASH,but will be there any function to copy data from FLASH to RAM.
Sincerely Shamsudheen OP
The code for copying Flash to RAM is correct and works on my LPC2368. You say that it is not working. Can you be more specific ?
You can check the memory contents at 0x58000 in the Memory window when you debug your application with ULINK. Then compare this to the buffer in RAM after you execute the lines for reading.
Hi Dear Shamsudheen!
I am trying to write some data to flash memory of LPC23xx , i have also used the same Flash code provided in the Keil Folder..LPC_IAP2_512...and using the main function same as you have posted which is as below..
#include "lpc23xx.h" #include "..\FlashOS.H" #include "typedef.h"
int main() {
U8 bTempBuff[512]={1,2,3,4,5} ; //RAM MEMORY LOCATION
U8 bStoreToRam[512]={'\0'}; //STORE TO RAM LOCATION
U8 b_Count = 0;
Init(0x00058000,4096000,2);
EraseSector (0x00058000); //ERASE SECTOR NUM
ProgramPage(0x00058000, 512 ,bTempBuff);
return(0);
But i get the following error after compilation can you point out what could be the problem...
LPC_IAP2_512.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST. LPC_IAP2_512.sct: Not enough information to list image symbols. LPC_IAP2_512.sct: Not enough information to list the image map. LPC_IAP2_512.sct: Finished: 2 information, 0 warning and 1 error messages. "LPC_IAP2_512.axf" - 1 Error(s), 0 Warning(s).