Dear Sir,
I am using ADUC841 microcontroller from Analog devices,which consists of 8052 core.In this it is having 4Kbytes of Flash data memory.I wrote the routines as mentioned in application note for writing the data in Flash.But the data is not storing in Flash.So,please send me some guidelines for writing the data in Flash.
Thanking you,
Yours sincerely, Shivakumar Manda
I had read the datasheet and according to that only i wrote one simple program to store the bytes in one page.Here I am sending the function statements to write the bytes in data memory.
void Flash_Mem_Write_Page(void) { EADRH=0x00; //Select Address hoiher byte EADRL=0x01; //Select addres lower byte
EDATA1=0x12; //writing the data EDATA2=0x13; EDATA3=0x14; EDATA4=0x15;
ECON=0x02; //writing the bytes Sleep(40); ECON=0x04; //verifying Sleep(22);
if(!ECON) //match is there it will return 0in ECON printf("WRITE\n"); else printf("NOT WRITE\n"); }
Thank you very much for replying.
"I had read the datasheet"
I hope you read it more carefully than the instructions here for posting source code:
www.danlhenry.com/.../keil_code.png
You also, apparently, didn't notice the problem in the 'Preview' - I hope you've reviewed your own code more carefully?
First, you said, "I wrote the routines as mentioned in application note"
Now you say, "I had read the datasheet and according to that only i wrote one simple program" (my emphasis)
So which is it - datasheet or application note?
or both?
or what?
Look at followed example. It works on ADuC847.
// **************************************************** // save 4 bytes to addr 0x3FF // **************************************************** void SaveSetPointToFlash(unsigned char* puc) { EA = 0; // Disable interrupts before saving EADRH = 0x03; // High byte of page Address EADRL = 0xFF; // Low byte of page Address EDATA1 = puc[0]; // Data to flash EDATA2 = puc[1]; // Data to flash EDATA3 = puc[2]; // Data to flash EDATA4 = puc[3]; // Data to flash ECON = 0x05; // Erase Page ECON = 0x02; // Write Page ECON = 0x04; // Verify Page EA = 1; // enable interrupts after saving }
As notes Christoph you should provide erasing page and remove delays.