We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Anybody got any experience with writing to Flash Code Memory in User Application Mode? I'm trying to write code to upgrade firmware in the field, but am unable to successfully overwrite more than just a few pages of new firmware into the MSC1210 flash code memory.
I've written successfully to the Flash data memory (but only actually needed to write 2 or 3 pages), and am aware of the problems with running code from flash whilst writing to it so I'm using the BootRom routines.
I'm trying to write 8k of new code over the first 8k of code space. I've made sure that my code to do this is high up in memory - around 24k - it's written in C and I've looked at the generated assembler to make sure no calls to any "helper" routines elsewhere are getting called (other than the routines in the bootrom of course). my code is something like:
for (i = 0; i < 64; i++) //64 pages in total in 8k { address = i * 128; src = &xMem.Code[address]; if (page_erase(address, 0, FPM) == 0) { for (j = 0; j < 128; j++) { hex = *src++; write_flash_chk(address, hex, FPM); address++; } } }
Its a simple loop to write 64 pages, each page 128 bytes 1 byte at a time. It mostly gives up the ghost at around page 10 or 11 -occasionally it will write 17 or 18 pages.
If I make the outer loop (i = 30; i < 32; i++) it writes those page ok, so It doesn't seem to be an addressing problem. I've played around with lots of different values in the FTCON (flash timeing control) register with no better success.
Anybody got any ideas?
"User Application Mode" here relates (as the thread subject implies) to the programming of the internal flash memory - other modes in this respect are Serial Programming mode and Parallel programming mode. Nothing at all to do with the mode of the processor - though whilst in either the Parallel or Serial programming modes the processor is to all intents and purposes idle.
Rod.