C program to generate 1 kHz square wave on Pin 2 of Port T

C program toc2_sw.c
/* Program to generate a 1 kHz square wave */

#include "hc12.h"
#define HALF_PERIOD 4000             /* 4000 cycles = 0.5 ms */

main()
{
    TSCR = 0x80;                     /* Turn on timer subsystem */
    TMSK2 = 0x00;                    /* Set prescaler for 8 ms overflow rate */

    /* Setup for OC2 */
    TIOS = TIOS | 0x04;              /* IOC2 set for Output Compare */
    TCTL2 = (TCTL2 | 0x10) & ~0x20;  /* Toggle on compare */
    TFLG1 = 0x04;                    /* Clear IC2 Flag */
    TMSK1 = TMSK1 | 0x04;            /* Enable TOC2 interrupt */

    enable();                        /* Enable general interrupts */

    while (1)                        /* Do nothing */
    {
        _asm("wai");
    }
}

@interrupt void toc2_isr(void)
{
    TC2 = TC2 + HALF_PERIOD;          /* Toggle after 0.5 ms */
    TFLG1 = 0x04;                     /* Clear IC2 flag */
}

Interrupt vector file vector.c
/*      INTERRUPT VECTORS TABLE 68HC12
 */

void toc2_isr(void);

/* Vectors at 0xFFD0 on standard HC12; remapped to 0x0B10 with D-Bug 12 */
void (* const _vectab[])() = {
        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           */
        };