Hello, and thank you for reading.
I am loading program code into a customized memory segment map on an MSP403F4152:
SEGMENT SPACE START ADDRESS END ADDRESS SIZE TYPE ALIGN
======= ===== ============= =========== ==== ==== =====
DATA16_AN 0001 - 0003 3 rel 0
0019 - 001B 3
001D - 0026 A
...
0192 - 0193 2
01B0 - 01B5 6
DATA16_I 0200 dse 0
DATA16_Z 0200 - 021D 1E rel 1
CSTACK 03B0 - 03FF 50 rel 1
MONITOR C000 - C285 286 rel 1
DATA16_C C400 - C4AB AC rel 1
CSTART C4AC - C4C3 18 rel 1
<CODE> 1 C4C4 - E069 1BA6 rel 1
INTVEC FFE0 - FFF9 1A com 1
RESET FFFE - FFFF 2 rel 1
My main() function and related code is being placed into 0xC400-0xFFFF. A separate function called firmware() is being placed into a segment named MONITOR at location 0xC00-0xC3FF. The firmware() function is used to erase 0xC400-0xFFFF and then reprogram it with updated code through a UART. This has worked well for us for years, but recently we tried to simplify our manufacturing process by combining all the code into a single project and programming the chip in 1 pass instead of 2 passes. After this combination, everything still works as expected up until the firmware() function erases 0xC400-0xFFFF. At that point, the local variables in the firmware() function appear to become corrupted. For example, a left shift operation on a local unsigned char results in an erroneous value.
Does anyone recognize this problem, or have any suggestions? I have tried all sorts of hacks such as placing the firmware() local variables in a separate named segment. Just to be clear, everything works correctly after the following: we load firmware() as a main() function within project #1 into 0xC000-0xC3FF, then load our appilcation code as a main() function within project #2 into 0xC400-0xFFFF while retaining unchanged memory. Everything still works if we combine the code into a single project and place firmware() using a customized memory segment map, until we use firmware() to erase the other parts of memory.