I need to store my boards network ID into nonvolatile memory. I have been using the page_erase() and write_flash_chk():
page_erase(PAGE_START, 0xFF, FDM); write_flash_chk(PAGE_START, NewAddr, FDM);
PAGE_START = 0x0400
//FLASH WRITE CONFIGURATION USEC = 0x0C; //tFWT = 32.5 us MSECH = 0x4E; //MSEC for tFET = 10 ms MSECL = 0x20; // @32 MHz FTCON = 0xFF; //FWR = 0x0F & FER = 0x0F
PAGE_START = 0x0400 That worked fine until I changed my Serial ISR did that make 0x400 - end of page contain code? Erik
Erik, I thought I had checked that. The place to look would be the M51 file, right?
right, but remember the "high number" is the START of the last module, I got caught on that one once. Erik
Erik, In the map file I noticed the following:
CODE 0026H 0529H UNIT ?PR?_TUNECHANNEL?AUTOTUNE
Well, if you have data in the middle of the code segment, you'll have to tell the linker about that, so it can leave that area alone. In LX51, the relevant directive is RESERVE.
I am a little confused about the memory layout, becasue I am new to the 8051 environment. I am using the MSC1210Y5. By configuring HCR0, I have partitioned 1kb for Data flash memory and 31kb for program flash memory. I am assuming the C51 compiler won't differenciate between the two, so I have to tell it where to start the code?
Yes, if there's a region of CODE memory space that isn't available for running code out of it, somebody has to tell the linker about that. If the tools aren't doing it by themselves (--> check out the "use memory layout from target dialog button), you have to do it yourself. Are you sure the CODE space memory hole has to be at 0x0400? Can't you configure it to be at a more sensible place like, say, at the end of those 32 KiB, from 0x7c00 to 0x7fff?
Are you sure the CODE space memory hole has to be at 0x0400? Can't you configure it to be at a more sensible place like, say, at the end of those 32 KiB, from 0x7c00 to 0x7fff? Well all the documentation I have read said that data flash memory starts at 400h. I tried having my code start at 500h, but my program no longeer detects the interrupts...
Well all the documentation I have read said that data flash memory starts at 400h I do not know what "documentation" you refer to but my guess is that a careful reading would lead to the understanding that "dual purpose flash memory starts at 400h". I do not know your chip, but were I to design a chip with "dual purpose flash" I would, by some means, protect page 0 from "wild writes" Erik
The documentation I am refering to is the MSC1210 Users Guide...and I have no problem writing to that memory space. The problem is trying to erase it and write to it again..
The documentation I am refering to is the MSC1210 Users Guide...and I have no problem writing to that memory space. The problem is trying to erase it and write to it again.. some has been answered at 8052.com, I agree with the poster that suggested you locate your data at the top of memory. Try that and come back Erik
Erik, On 8052.com Craig suggested I turn of interrupts before doing a page erase. That solved the problem. In the previous veresion I had I wasn't turning off interrupts but it worked, so I am curious to see why! Thank you and everyone else for all your help.
"In the previous veresion I had I wasn't turning off interrupts but it worked, so I am curious to see why!" My Theory: http://www.8052.com/forum/read.phtml?id=100395
Andy, Pure luck is right. I had this board running for months without a problem. I changed one thing and it went down. Thanks for the insight.
"I had this board running for months without a problem" No: you had that board running for months with a problem - you were just lucky enough that the problem never manifested itself! It's that 'Proven Product' Syndrome again: http://www.8052.com/forum/read.phtml?id=78339 Cue: Erik on "Testing" ...