Hello Everyone,
I am attempting to create firmware which is capable of over writing the main code (in the flash memory) with new code. After doing some research among these forums, I decided to use the method where some code (flash erase/write ect) is copied into the RAM and executed there, in order to erase code memory. Using the example code found here: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/72156/262251.aspx#262251 I was able to create code which can be executed from RAM. However, when erasing segments of the main memory, the code running in the RAM does not continue to execute. This general idea of the RAM executed code is shown below. The processor used is an MSP430F2112.
// Function which has previously been copied to RAM.
#pragma CODE_SECTION(ram_funct,".FLASHCODE")
void ram_funct(void)
{
// Set test LED1.
P3OUT |= 0x04;
// Erase segments of main code
ram_erase(0xF800); // Works fine
ram_erase(0xF900); // Works fine
ram_erase(0xFA00); // Problem here - debugger cannot continue to step through
// Set Test LED2.
P3OUT |= 0x08; // Line never reached, LED2 NOT set.
// Since there is now no code in code memory, loop here in RAM forever.
while (1)
{
__no_operation();
}
}
note: ram_erase is another function located in RAM.
My understanding is that this code should continue to run even after all the flash code is erased, since it is running from RAM, which it does not appear to do.
I also am curious as to how I would execute new code once it is copied into the code memory. Would some sort of reset be needed? Or is it possible to jump to the first line of the new code, at the end of the RAM executed function?
Any insights would be greatly appreciated.
- Jake