I ported a sector erase (in C) from 1.31 to uVision 2.20a using ap note 138 (etc.). (C161O, flash 0x0 - 0x3FFFF, ram 0x80000-0x8FFFF; 16 MHz.) After entering main() and before enabling interrupts, we erase a sector and then continue with initialization, and enabling interrupts, and the application. When I run the simulator, I can step through the code to verify that I am passing parameters to the erase function and that the function returns properly. However, running the target, the app gets lost. I examine the flash in the prom programmer and can verify that the application has erased the sector as expected. Did ap note 138 omit to describe any options (for example: NOFIXDPP) in Options-C166-Misc Controls or Options-L166 Misc?
It seems that you can't debug your application using Monitor166. That's very unfortunate. If there is a display in your target hardware you can print some diagnostic messages to find out at which point exactly the program crashes. - Mike