Using Output Compare to generate a square wave

C program
/*
 * Program to generate square wave on PT2
 */
#include "hc12.h"

#define PERIOD      0x2000
#define HALF_PERIOD 0x1000

#define TRUE       1 

main()
{
	/* Turn on timer subsystem */
	TSCR = 0x80;
	/* Set prescaler to 8 */
	TMSK2 = 0x03;

	/* Configure PT2 as Output Compare */
	TIOS = TIOS | 0x04;
	/* Set up PT2 to toggle on compare */
	TCTL2 = (TCTL2 | 0x10) & ~0x20;
	/* Clear flag and enable interrupt on C2 */
	TFLG2 = 0x04;
	TMSK1 = TMSK1 | 0x04;

	enable();

	while (TRUE) ;
}

@interrupt void toc2_isr(void)
{
	TC2 = TC2 + HALF_PERIOD;
	TFLG1 = 0x04;
}
Interrupt vector file vector.c
/*      INTERRUPT VECTORS TABLE 68HC12
 *      Copyright (c) 1996 by COSMIC Software
 */
void toc2_isr();

void (* const _vectab[])() = {   /* 0x0B10 */
        0,              /* BDLC            */
        0,              /* ATD             */
        0,              /* reserved        */
        0,              /* SCI0            */
        0,              /* SPI             */
        0,              /* Pulse acc input */
        0,              /* Pulse acc overf */
        0,              /* Timer overf     */
        0,              /* Timer channel 7 */
        0,              /* Timer channel 6 */
        0,              /* Timer channel 5 */
        0,              /* Timer channel 4 */
        0,              /* Timer channel 3 */
        toc2_isr,       /* Timer channel 2 */
        0,              /* Timer channel 1 */
        0,              /* Timer channel 0 */
        0,              /* Real time       */
        0,              /* IRQ             */
        0,              /* XIRQ            */
        0,              /* SWI             */
        0,              /* illegal         */
        0,              /* cop fail        */
        0,              /* cop clock fail  */
        (void *)0xff80, /* RESET           */
        };