Note I've never used an MCF51-anything. I'm just reading the manuals and going from experience with other chips.
> P&E USB Multilink BDM version C
Make sure it has the "clock" jumper inside it set properly. Rumour has it it has to be set to "NO CLK" for most devices. I think I remember it only ises "with clk" for some very old CPUs. Check this on P&E's site or google it.
> debugger consistently looses contact with the target when the code loads the MCGTRM register.
If there's a loose contact you just have to tighten it up (sorry :-).
With what value from what value? The Manual says it defaults to 0x80 when run from the debugger, which is different from the normal operation where it loads that register from a Factory location.
Check that it is loaded with 0x80 as expected. Then try loading it with the same value and see if you LOSE the connection. If that's OK, try changing it by "1" then "2" and so on. There may be a maximum change value that you can use to retain control. Then change the code to stay under that value, or maybe change it in small steps.
What value is the code loading into MCGTRM? It may be getting a zero or all-ones value from somewhere. It may be reading the "Factory" trim location and you may not have that programmed or set properly when running under the debugger.
You can always write a "debug version" of the bootloader that you only run under the debugger that avoids doing problematic things. Once you've got your new code working you revert to "normal" run mode. You could also write a boot version that checks some registers to find if it us running under the debugger and behaves differently. You may find you need to debug the loader in "external crystal" mode on a development board if that is possible.
If you can't step THROUGH the code that loads MCGTRM can you set a breakpoint after that point and RUN through it?
Tom