/*********************************************
 * includes.h
 *
 * Insert things common to all modules here
 ********************************************/
#include 
#define  P_CLOCK_FREQ  8000000L

// Constants
#define LED_COUNT_MAX  488
#define BEEP_COUNT_MAX 100

// Function prototypes
void UpdateLED(void);
void UpdateBeep(void);
void DelayGate(void);

/* end of includes.h */

The following is the main file.  After the real time clock and DLC port are initialized, the main program loop begins.  Rather than using a constant value to control the main while-loop, the variable done is used in a simple trick to prevent a compiler warning.  The UpdateLED task is triggered periodically and the UpdateBeep task starts triggering with a flag.

/**************************************************
 * BlinkBeep - main.c - Jonathan Hill
 * A demonstration of a super loop application.  
 * Blinks an LED and produce a beep sound
 *************************************************/
#include "includes.h"

// Global variables
int BeepFlag = 0;

// The main loop
void main(void)  {

  int done = 0;
  RTICTL  = 0x01; //set RTI timer to minimum delay
  PORTDLC = 0x00; //initialize port register
  DDRDLC  = 0x07; //set pin to output
  
  while (!done) { // Perform tasks in order
    UpdateLED();
    UpdateBeep();
    DelayGate();
  }
}

/**************************************************
 * UpdateLED()
 *
 * When the LED count runs out, toggle and beep
 *************************************************/
void UpdateLED(void)
{
  static int LedCount = LED_COUNT_MAX;
  
  if (--LedCount == 0) {
    BeepFlag = 1;
    LedCount = LED_COUNT_MAX;
    PORTDLC ^= 0x01;
  }
}

/**************************************************
 * UpdateBeep()
 *
 * If the Beep is started, then update the speaker
 *************************************************/
void UpdateBeep(void)
{
  static int BeepCount = BEEP_COUNT_MAX;
  if (BeepCount != 0) {	    // Active - Toggle spkr
    BeepCount--;
    PORTDLC ^= 0x06; }
  else if (BeepFlag != 0) { // Request - Start beep
    BeepFlag = 0;
    BeepCount = BEEP_COUNT_MAX;
    PORTDLC |= 0x04; }
  else {                   // Off - Silence speaker
    PORTDLC &= 0xF9;
  }
}

/**************************************************
 * DelayGate
 *
 * Wait for timeout, then restart the RTI clock
 *************************************************/
void DelayGate(void)
{
  while (RTIFLG == 0) ;
  RTIFLG = 0x80;
}
