You code doesn't look right.
1. MCCNT is not writeable in normal modes, ECT_MCCNT = 2000 won't work without BDM pod connected.
2. MCCNT is upcounting. If MCCNT would accept MCCNT = 2000, condition ECT_MCCNT >=5 would be true about 65536-2000-5 timer ticks, almost 2ms @32MHz. You code works because in special mode (when BDM pod is attached and you aren't using hotplug debugging), writing anything to MCCNT resets MCCNT.
This should work in all modes (not tested):
signed int targettcnt;
for(;
{
targettcnt = TCNT + 2000;
while( (signed int)(TCNT - targettcnt) < 0) ) {}
PTP ^= (1<<3);
}
But jitter still will be high compared to automatic pin action on timer output compare, or compared to PWM. Here's the code (not tested) for 8kHz square wave on PP3/PWM3
PWMPER23=4000; // 32M / 8k
PWMDTY23=2000;
PWMCTL |= PWMCTL_CON23_MASK; // concatenate PWM 2 and 3
PWME |= (1<<3);