I am using the MC9S12E128 processor (80pin) and have a problem where the BDM sometimes looses control of the microcontroller and no further debugging is possible after executing the PLLSEL = 1 instruction (sets PLLSEL bit in the CLKSEL register). The program usually jumps to 0xFFFF. This happens every second or third time after programming the micro. Note that it makes no difference if I single-step to this instruction or run to this instruction.
If the PLLSEL = 1 instruction happens to be executed correctly then I can reset and run it correctly every time after that until reprogramming the chip again. Suggests a programming problem?
The PLL registers are set to SYNR = 0x0B and REFDV = 0x01, with a crystal frequency of 3.6864MHz. This gives a bus frequency of 22.1184MHz. Supply voltage is 3.1V.
The SYNR register is set first. Then the REFDV register. Once the PLL locks (checked via the LOCK bit in CRGFLG register), the PLL is selected.
Any suggestions are welcome!